Closed casperisfine closed 2 years ago
neat idea.
Just having a baseline option (where we assume the first is the baseline?) may be minimal changes.
you would just need:
best = entries.shift if baseline?
sorted = entries.sort_by{ |e| e.stats.central_tendency }.reverse
best ||= sorted.shift
and the changes to handle faster
/slower
Yeah I feel like most of the time you just put the baseline first right?
Seems like an option like x.compare!(order: :baseline)
would work?
I feel like most of the time you just put the baseline first right?
That's my case at least yeah.
an option like x.compare!(order: :baseline) would work?
Sounds good to me, I'll try that.
Done.
I couldn't really see how to test it however, as the current test don't really cover the rendering.
@evanphx done.
Not sure if is more clear to introduce another report
: baseline(:original) {}
(this current PR does this)
Or just introduce a variable. report('original') {} ; self.baseline='original'
(and that variable, like warmup
could come in any of a number of ways)
Yeah I feel like most of the time you just put the baseline first right?
Seems like an option like
x.compare!(order: :baseline)
would work?
ooh. I think I spoke too soon. So you do not introduce baseline
block or variable at all, just order
. That is potentially nice.
code looking nice @casperisfine
Thanks!
Release coming today or tomorrow
This is just a quick proof of concept to gather some feedback, I totally realize it's likely not desirable to change the existing behavior, but I'm willing to do the work to put this behind an option of some sort.
Use case.
Most of the time when I use
benchmark-ips
, it looks like this:Giving a result like:
But maybe it's just me, I find this output a bit confusing, because what I want to know is how much slower/faster each optimization is compare to "the baseline", which generally is the first registered
x.report
.So something like this:
Which is pretty much what I implemented in a quick and dirty way.
Possible API
So if this feature were to be accepted, what would be the syntax for it?
I'm thinking that it could be mark by using
x.baseline
instead ofx.report
?: