Independent Benchmarking
Opened this issue · 3 comments
I wonder if this would make a difference in these benchmarks:
If you are comparing multiple implementations of a piece of code you may want to benchmark them in separate invocations of Ruby so that the measurements are independent of each other. You can do this with the
hold!
command.
— https://github.com/evanphx/benchmark-ips#independent-benchmarking
Huh....TIL...I'll see about adding this @fractaledmind
I admittedly stole these benchmarks from ViewComponent. I pretty much have no idea what I'm doing...
Results are similar, then annoying thing is you need to do something like this to get it to run all the invocations:
for run in {1..7}; do ruby benchmark.rb; done
Results:
Comparison:
papercraft: 16159.6 i/s
phlex: 13636.5 i/s - 1.19x slower
ruby2html: 13486.6 i/s - 1.20x slower
view_component: 7445.1 i/s - 2.17x slower
cells: 3896.8 i/s - 4.15x slower
partials: 3402.3 i/s - 4.75x slower
dry_view: 452.5 i/s - 35.71x slower
For some benchmarking I was doing, what I did was simply create two Ruby files, called bench.rb
and meta.rb
. I run ruby meta.rb
, and that runs bench.rb
multiple times in different setups. This also then allowed me to do some extra setup and post-processing work in meta.rb
. Gist here: https://gist.github.com/fractaledmind/56329e5893777dbf43b8c480df554bfb