martijn / xsv

High performance, lightweight .xlsx parser for Ruby that provides nothing a CSV parser wouldn't
https://storck.io/posts/announcing-xsv-1-0-0/
MIT License
194 stars 20 forks source link

Simplify XML parser using IO#gets #42

Closed martijn closed 2 years ago

martijn commented 2 years ago

Turns out this is actually a lot slower and allocating more due to how #read is implemented in Rubyzip. This is probably why I went with sysread initially :)

./benchmark.rb on main

--- ARRAY MODE ---
Performance benchmark: 1.0193964000092819s avg 0.009340342315816343s stdev
Calculating -------------------------------------
                       883.133M memsize (     1.007k retained)
                         2.373M objects (    12.000  retained)
                        50.000  strings (     2.000  retained)

--- HASH MODE ---
Performance benchmark: 1.4067317999899387s avg 0.04825439805105081s stdev
Calculating -------------------------------------
                       886.334M memsize (     1.650k retained)
                         2.433M objects (    16.000  retained)
                        50.000  strings (     3.000  retained)

./benchmark.rb on bufferless-parser

--- ARRAY MODE ---
Performance benchmark: 2.526302199973725s avg 0.02019858371069751s stdev
Calculating -------------------------------------
                         8.051B memsize (     1.007k retained)
                         3.593M objects (    12.000  retained)
                        50.000  strings (     2.000  retained)

--- HASH MODE ---
Performance benchmark: 3.0494400000199677s avg 0.17171053600326805s stdev
Calculating -------------------------------------
                         8.054B memsize (     1.650k retained)
                         3.653M objects (    16.000  retained)
                        50.000  strings (     3.000  retained)