JayBeams
0.1
Another project to have fun coding.
|
Run a micro-benchmark on a given class. More...
#include <microbenchmark.hpp>
Public Types | |
typedef jb::testing::microbenchmark_config | config |
![]() | |
typedef std::chrono::steady_clock | clock |
typedef clock::duration | duration |
typedef std::pair< int, duration > | result |
typedef std::vector< result > | results |
Public Member Functions | |
microbenchmark () | |
Default constructor, create a default configuration and initialize from it. More... | |
microbenchmark (config const &cfg) | |
Constructor from a configuration. More... | |
template<typename... Args> | |
results | run (Args &&... args) |
Run the microbenchmaark. More... | |
![]() | |
microbenchmark_base (microbenchmark_config const &cfg) | |
Constructor from a configuration. More... | |
void | typical_output (results const &r) const |
Produce the results of the test in a format that works for most cases. More... | |
void | write_results (std::ostream &os, results const &r) const |
Stream the detailed results. More... | |
Private Member Functions | |
template<typename... Args> | |
results | run_unsized (Args &&... args) |
Run a test without specifying the size and some additional arguments for the Fixture constructor. More... | |
results | run_unsized () |
Run a test without specifying the size and no additional arguments for the Fixture constructor. More... | |
template<typename... Args> | |
results | run_fixed_size (Args &&... args) |
Run the test when the size is specified in the microbenchmark configuration. More... | |
template<typename... Args> | |
void | run_sized (int size, results &r, Args &&... args) |
Construct a fixture for the given size and run the microbenchmkark. More... | |
void | run_base (Fixture &fixture, results &r) |
Run a microbenchmkark for a constructed fixture. More... | |
Static Private Member Functions | |
static void | run_iteration (Fixture &fixture, results &r) |
Run a single iteration of the test and return the results. More... | |
Additional Inherited Members | |
![]() | |
microbenchmark_config | config_ |
Run a micro-benchmark on a given class.
This class is used to run microbenchmarks. To use it, you wrap your function or class in a Fixture that constructs the unit under test and calls it. For example, consider a class like this:
To test the bar() function you would create a Fixture class like this:
Then you can run the test using:
The framework creates a single instance of the Fixture for the full test, it worries about running a warmup iteration, collecting the results with minimal overhead, and creating a sensible summary.
Fixture | A type meeting the following requirements: class Fixture { public: Fixture(Args ...); // default constructor, used for the default sized test Fixture(int s, Args ...); // constructor for a test of size 's' }; |
Definition at line 131 of file microbenchmark.hpp.
typedef jb::testing::microbenchmark_config jb::testing::microbenchmark< Fixture >::config |
Definition at line 133 of file microbenchmark.hpp.
|
inline |
Default constructor, create a default configuration and initialize from it.
Definition at line 139 of file microbenchmark.hpp.
|
inlineexplicit |
Constructor from a configuration.
Definition at line 146 of file microbenchmark.hpp.
|
inline |
Run the microbenchmaark.
args | the additional arguments, if any, for the Fixture constructor. |
Args | the types for the additional arguments. |
Definition at line 159 of file microbenchmark.hpp.
References jb::detail::reconfigure_this_thread().
Referenced by main().
|
inlineprivate |
Run a microbenchmkark for a constructed fixture.
Run the warmup iterations and then run the actual iterations for the test. The results of the test are ignored during the warmup phase.
fixture | the object under test |
r | where to store the results of the test |
Definition at line 234 of file microbenchmark.hpp.
References jb::testing::detail::call_iteration_setup(), and jb::testing::detail::call_iteration_teardown().
|
inlineprivate |
Run the test when the size is specified in the microbenchmark configuration.
args | additional arguments for the Fixture |
Args | the types for the additional arguments |
Definition at line 204 of file microbenchmark.hpp.
|
inlinestaticprivate |
Run a single iteration of the test and return the results.
fixture | the object under test |
r | where to store the results of the test |
Definition at line 254 of file microbenchmark.hpp.
References jb::testing::detail::call_iteration_setup(), jb::testing::detail::call_iteration_teardown(), and jb::testing::defaults::size.
|
inlineprivate |
Construct a fixture for the given size and run the microbenchmkark.
size | the size of the test |
r | where to store the results of the test |
args | additional arguments for the constructor, if any. |
Args | the types of the additional arguments, if any. |
Definition at line 219 of file microbenchmark.hpp.
|
inlineprivate |
Run a test without specifying the size and some additional arguments for the Fixture constructor.
args | additional arguments for the Fixture |
Args | the types for the additional arguments |
Definition at line 178 of file microbenchmark.hpp.
|
inlineprivate |
Run a test without specifying the size and no additional arguments for the Fixture constructor.
Definition at line 189 of file microbenchmark.hpp.