|
eztimer
Easy timing of C++ functions
|
Easy timing of C++ functions. More...
Classes | |
| struct | Options |
Options for time(). More... | |
| struct | Timings |
| Timings for each function. More... | |
Functions | |
| template<typename Result_ > | |
| std::vector< Timings > | time (const std::vector< std::function< Result_()> > &funs, const std::function< void(const Result_ &, std::size_t)> &check, const Options &opt) |
Easy timing of C++ functions.
| std::vector< Timings > eztimer::time | ( | const std::vector< std::function< Result_()> > & | funs, |
| const std::function< void(const Result_ &, std::size_t)> & | check, | ||
| const Options & | opt ) |
Record the execution time of any number of functions, possibly over multiple iterations. When multiple functions are supplied, they are called in a random order per iteration to avoid any dependencies. Burn-in iterations are performed at the start to ensure any initialization effects do not distort the timings. The per-function or total runtime can also be capped, in which case the actual number of iterations for a function may be less than Options::iterations.
| funs | Vector of functions to be timed. Each function should return a value that depends on the computation of interest, to ensure that the latter is not optimized away by the compiler. |
| check | Function that accepts a Result_ and an index of funs, and performs some kind of check on the former. Any check is fine as long as it uses the value returned by funs. The runtime of this function will not be included in the timings. |
| opt | Further options. |
funs.size(), containing the timings for each function.| Result_ | Result of each function call. |