Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce GC'able cache for Roo::Excelx::Extractor#doc
Memory Profiling script: ``` MemoryProfiler.report{Roo::Excelx.new('test/files/Bibelbund.xlsx').tap{|x|(2..x.last_row).each{|i| x.row(i)}}}.pretty_print ``` Benchmark Script: ``` puts Benchmark.measure{ Roo::Excelx.new('test/files/Bibelbund.xlsx').tap{|x|(2..x.last_row).each{|i| x.row(i)}} } ``` Result on Master: ``` Total allocated: 37131810 bytes (517026 objects) Total retained: 5562913 bytes (103010 objects) allocated memory by gem ----------------------------------- 19288066 roo/lib 11049821 nokogiri-1.8.4 6792403 rubyzip-1.2.2 1304 tmpdir 216 other retained memory by gem ----------------------------------- 5560934 roo/lib 782 rubyzip-1.2.2 725 nokogiri-1.8.4 296 tmpdir 176 other 0.720000 0.020000 0.740000 ( 0.733750) ``` Result after patch: ``` Total allocated: 34561842 bytes (504998 objects) Total retained: 5563553 bytes (103026 objects) allocated memory by gem ----------------------------------- 19254338 roo/lib 8513101 nokogiri-1.8.4 6792403 rubyzip-1.2.2 1304 tmpdir 320 weakref 216 other 160 ref-2.0.0 retained memory by gem ----------------------------------- 5561094 roo/lib 782 rubyzip-1.2.2 725 nokogiri-1.8.4 320 weakref 296 tmpdir 176 other 160 ref-2.0.0 0.610000 0.010000 0.620000 ( 0.618642) ``` Note: Ruby does have native implementation of WeakRef. But I've choosed to go with 'ref' gem for this following reason: https://github.com/ruby-concurrency/ref#problems-with-weakref
- Loading branch information