-
Notifications
You must be signed in to change notification settings - Fork 27
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
[3.2] benchmarking framework and its use in benchmarking crypto primitives #799
Conversation
Should we consider using https://github.com/google/benchmark which has built in support for preventing the compiler from optimizing out what you are trying to benchmark as well as other useful features for micro-benchmarking. |
The Google microbenchmarking library looks great. It has lots of features and more code. Just wondering if it is brought in, would it increase dependencies and build time? |
We will not move forward with Google benchmarking framework at this time, because it doesn't seem to have enough value add compared to current code used. |
|
||
target_link_libraries( benchmark fc Boost::program_options ) | ||
target_include_directories( benchmark PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be wrapped in quotes to handle spaces. You may also be able to just put a .
here since paths are relative to CMAKE_CURRENT_SOURCE_DIR
anyways. Or just forego it all together and include "benchmark.hpp"
but that's typically not the pattern we use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions. I will make changes.
I wonder if there should be a machine-readable output (like JSON) to make it easier to ingest in to some reporting framework. |
uint64_t total {0}, min {std::numeric_limits<uint64_t>::max()}, max {0}; | ||
|
||
for (auto i = 0U; i < num_runs; ++i) { | ||
auto start_time = std::chrono::steady_clock::now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like high_resolution_clock
is what we would want when making tiny measurements like this, but it's not a monotonic clock on libstdc++ 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it matters for this use case if the clock is not monotonic. It's only a relative number that is just needed for orders of magnitudes and comparisons. So, I agree that this should be high_resolution_clock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Will change to use high resolution clock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only needing relative times is exactly the use for monotonic clocks. It is probably okay to use a non-monotonic clock, but that's because the small chance of producing wild results if the system clock happens to change while running the benchmark is a manageable problem.
I will add a -j option for JSON format output. |
That would be nice to have, but maybe we can list that as a phase 2 item for after this is merged and done. |
Close this as it is being ported over to Leap as AntelopeIO/leap#17. |
Resolve #786 and partially resolve #780.
Implement a benchmarking framework to help writing benchmarking code by reusing common measuring functions and unifying reports. After the PR is approved, the framework can be used to benchmark other functions.
For end users
Below are a few examples
Help
Benchmarking All Modules (functions)
Benchmarking Particular Module with Specific Number of Runs
For developers
Please see
alt_bn_128.cpp
andmodexp.cpp
for examples.The general approach to adding code to benchmark a set of functions is
benchmarking
.modules
inbenchmark.cpp
.