1 #ifndef jb_testing_microbenchmark_hpp 2 #define jb_testing_microbenchmark_hpp 23 template <
typename Fixture,
typename... Args>
37 typename = decltype(std::declval<Fixture>().iteration_setup())>
39 fixture.iteration_setup();
51 template <
typename Fixture,
typename... Args>
65 typename = decltype(std::declval<Fixture>().iteration_teardown())>
67 fixture.iteration_teardown();
130 template <
typename Fixture>
158 template <
typename... Args>
160 if (config_.reconfigure_thread()) {
163 if (config_.size() != 0) {
164 return run_fixed_size(std::forward<Args>(args)...);
166 return run_unsized(std::forward<Args>(args)...);
177 template <
typename... Args>
179 Fixture fixture(std::forward<Args>(args)...);
181 run_base(fixture, r);
192 run_base(fixture, r);
203 template <
typename... Args>
206 run_sized(config_.size(), r, std::forward<Args>(args)...);
218 template <
typename... Args>
220 Fixture fixture(size, std::forward<Args>(args)...);
221 run_base(fixture, r);
235 for (
int i = 0; i != config_.warmup_iterations(); ++i) {
242 r.reserve(r.size() + config_.iterations());
243 for (
int i = 0; i != config_.iterations(); ++i) {
244 run_iteration(fixture, r);
256 auto start = clock::now();
257 int size = fixture.run();
258 auto stop = clock::now();
260 r.emplace_back(std::make_pair(size, stop - start));
268 #endif // jb_testing_microbenchmark_hpp
void run_sized(int size, results &r, Args &&... args)
Construct a fixture for the given size and run the microbenchmkark.
std::vector< result > results
void call_iteration_teardown(Fixture &&, Args &&...)
A helper to call Fixture::iteration_teardown() in the microbenchmarks.
static void run_iteration(Fixture &fixture, results &r)
Run a single iteration of the test and return the results.
results run(Args &&... args)
Run the microbenchmaark.
results run_fixed_size(Args &&... args)
Run the test when the size is specified in the microbenchmark configuration.
results run_unsized(Args &&... args)
Run a test without specifying the size and some additional arguments for the Fixture constructor...
Configure a micro-benchmark.
void call_iteration_setup(Fixture &&, Args &&...)
A helper to call Fixture::iteration_setup() in the microbenchmarks.
void reconfigure_this_thread(thread_config const &config)
Change the current thread parameters based on the configuration.
microbenchmark(config const &cfg)
Constructor from a configuration.
Refactor non-template parts of the microbenchmark template class.
microbenchmark()
Default constructor, create a default configuration and initialize from it.
Run a micro-benchmark on a given class.
jb::testing::microbenchmark_config config
void run_base(Fixture &fixture, results &r)
Run a microbenchmkark for a constructed fixture.
results run_unsized()
Run a test without specifying the size and no additional arguments for the Fixture constructor...
The top-level namespace for the JayBeams library.