evanphx / benchmark-ips

Provides iteration per second benchmarking for Ruby
MIT License
1.72k stars 97 forks source link

Provide Benchmark.quick_compare to quickly compare methods on an object #134

Closed evanphx closed 1 month ago

evanphx commented 9 months ago

Closes #133

Any feedback welcome, especially from @zenspider

nateberkopec commented 2 months ago

I'm back from the dead.

  1. I too don't like polluting Kernel by default. I think it's fine if we don't require 'benchmark/ips/quick by default. But, then you're kind of missing the point of this whole feature ofc because now you have to add another 15 characters at the top of your benchmark. In my head, the interface that makes the most sense is actually Benchmark.ips_quick_compare but I'm neutral and would be fine with Benchmark::IPS.quick_compare.
  2. I agree that benchmark/ips is about more than microbenchmarking, but microbenchmarking is cool too so we should minimize overhead where it's easy to do so.
  3. Supporting 2.3 is rad and doesn't block this feature

If no one objects I'll pick this up and run w/it

nateberkopec commented 1 month ago

I've changed it to my take.

  1. I tried @eregon's suggestion to send it directly to reduce overhead BUT that means you can't just define a method on main/Kernel and then quick compare it, because that method you just defined is private. The more important part of this feature is convenience rather than suitability for microbenching, so I decided to keep __send__
  2. It's been moved to Benchmark.ips_quick.
  3. Expanded docs.

LMK about objections, otherwise I'll add a test and merge

nateberkopec commented 1 month ago

Thanks for everyone's feedback. This should be the final form now, incl. a basic test. If no objections, will merge in a few days.