k0kubun / hamlit

High Performance Haml Implementation
https://rubygems.org/gems/hamlit
Other
981 stars 59 forks source link

make benchmark to more accurate. #47

Closed walf443 closed 8 years ago

walf443 commented 8 years ago

benchmark/ext/build_data.rb

Both benchmark includes string allocation. Faml::AttributeBuilder includes hash building. (It maybe fair to include hash building for Faml::AttributeBuilder considering real world situation.)

But this benchmark's interest is pure speed between Faml::AttributeBuilder.build and Hamlit::AttributeBuilder.build_data. So it may be more acurate by removing that code.

BEFORE

Calculating -------------------------------------
      Faml::AB.build    10.567k i/100ms
   Hamlit.build_data    10.125k i/100ms
-------------------------------------------------
      Faml::AB.build    165.685k i/s (0.006ms) -    834.793k
   Hamlit.build_data    153.934k i/s (0.006ms) -    769.500k

Comparison:
      Faml::AB.build:   165684.7 i/s (0.006ms)
   Hamlit.build_data:   153933.8 i/s (0.006ms) - 1.08x slower

AFTER

Calculating -------------------------------------
      Faml::AB.build    11.028k i/100ms
   Hamlit.build_data    10.134k i/100ms
-------------------------------------------------
      Faml::AB.build    182.088k i/s (0.005ms) -    915.324k
   Hamlit.build_data    156.376k i/s (0.006ms) -    790.452k

Comparison:
      Faml::AB.build:   182088.4 i/s (0.005ms)
   Hamlit.build_data:   156376.3 i/s (0.006ms) - 1.16x slower
k0kubun commented 8 years ago

Ah, I didn't recognize it had cost to build Hash object. Thank you.