#JMH - AverageTime or SampleTime
1 messages · Page 1 of 1 (latest)
bump :-)
Throughput = average number of operations per second
AverageTime = reverse of Throughput, average time of the operation
SampleTime = randomly take a sample and do the average of it
SingleShot = only call it once
It's exlained in the doc
But what is SampleTime doing exactly ? No idea.
I usually just use Throughput
Depends on the type of benchmark but I usually default to avgt, average time in the beginning because that will also give you a sanity check of how much time something actually took if you are familiar with the machine its being run on if you scale the timeunit with it. For example, if you have some block of code that does maybe some divisions or updating a value (write to RAM) and it's giving back a avg runtime of 0.8ns, then you know something is wrong with your benchmark because the computer can't do all those operations that fast.
Throughput, in this scenario, might give some massive number per timeunit and it's hard to just look at that value and say 'oh yea, a billion ops is reasonable."
Many benchmarks though are comparisons and throughput is fine but the point is that if you are writing benchmarks wrong then comparing two wrong benchmarks isn't going to help much.
Throughput is just 1/avgt
so it's not reasonable imo, I use this by default
But he was specifically asking for what is SampleTime, do you have an idea of which difference it could give ?
I never use sample time. I'm not clear on when it should be used. Perhaps on code that can take many branches.
blocking code? Don't know.
I'll say that I never see examples of it being used.
@covert rose
Your question has been closed due to inactivity.
If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure 👍