-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add standard deviation to benchmarking #1604
Conversation
Quick note before I start going through the commit -- please ensure that when using C stdlib, the includes and namespacing aligns. In other words, you should qualify the call as Not doing so breaks VxWorks and QNX. |
Codecov Report
@@ Coverage Diff @@
## master #1604 +/- ##
=========================================
- Coverage 80.72% 80.3% -0.42%
=========================================
Files 121 121
Lines 3424 3442 +18
=========================================
Hits 2764 2764
- Misses 660 678 +18 |
Codecov Report
@@ Coverage Diff @@
## master #1604 +/- ##
==========================================
- Coverage 80.72% 80.49% -0.24%
==========================================
Files 121 121
Lines 3424 3434 +10
==========================================
Hits 2764 2764
- Misses 660 670 +10 |
@horenmar good catch, fixed it. |
Okay, so I went through the changes and I think the PR needs to be done a bit differently. I think the end state should be that there is still just one |
I added a commit that shows the desired interface and usage 😃 Also the resulting output will need to be able to differentiate between the number of measurements and the number of iterations in a single measurement, so that will need some extra changes in the reporter and the BenchmarkInfo/BenchmarkStats struct. |
@horenmar I see your point. as I've also started by just changing base looper :) There are two points related to that I would like to discuss:
What do you think about this two? How should we solve them? |
The deviation should still be measured properly, if it is done right. Let's say there are 10 iterations per measurement, and the time taken per each measurement is T1, T2, ..., Tn. Ta is then the average of single iteration, that is a sum over Ti divided by N * 10. Variance is then the sum over all iterations as (Ti/10 - Ta)^2 / (N * 10). |
Ah you already fixed everything :) (long weekend here in Sweden :) ) I still don't think we can call it sigma in case if timer resolution is not enough. Because the value that we get is smaller than a value we would get with infinitely precise timer. Let me explain it like this:
|
On further inspection I agree, but I also think I am going to close this PR in favour of #1616, which will bring in a fully featured benchmarking and is going forward faster than I originally expected. |
Description
This PR adds standard deviation calculation to benchmark feature.
Deviation is useful when benchmarking OS dependent things: for example how long it takes to create a thread. Normal benchmark will only return a mean value like 100 us, but deviation will return a sigma, for example 20 us. Via 68–95–99.7 rule we can conclude that 95% of threads creations will be completed in [100 - 2 * 20, 100 + 2 * 20] = [60, 140] us.
Please let me know how can I improve it :)