Chebyshev
Unit testing for scientific software
|
Benchmark module. More...
Namespaces | |
generator | |
Input generators for benchmarks. | |
Classes | |
class | benchmark_result |
Structure holding the results of a benchmark. More... | |
class | benchmark_options |
A structure holding the options of a benchmark. More... | |
class | timer |
Timer class to measure elapsed time in milliseconds. More... | |
class | benchmark_settings |
of the benchmark module More... | |
class | benchmark_results |
benchmarks. More... | |
Typedefs | |
template<typename InputType > | |
using | InputGenerator = std::function< InputType(unsigned int)> |
A function which takes in an index and returns a generated input element. | |
Functions | |
void | setup (std::string moduleName, int argc=0, const char **argv=nullptr) |
Setup the benchmark environment. More... | |
void | terminate (bool exit=true) |
Terminate the benchmarking environment. More... | |
template<typename InputType , typename Function > | |
long double | runtime (Function func, const std::vector< InputType > &input) |
Measure the total runtime of a function over the given input for a single run. More... | |
template<typename InputType = double, typename Function > | |
void | benchmark (const std::string &name, Function func, const std::vector< InputType > &input, unsigned int runs=settings.defaultRuns, bool quiet=false) |
Run a benchmark on a generic function, with the given input vector. More... | |
template<typename InputType = double, typename Function > | |
void | benchmark (const std::string &name, Function func, const benchmark_options< InputType > &opt) |
Run a benchmark on a generic function, with the given options. More... | |
template<typename InputType = double, typename Function > | |
void | benchmark (const std::string &name, Function func, unsigned int runs=settings.defaultRuns, unsigned int iterations=settings.defaultIterations, InputGenerator< InputType > inputGenerator=generator::uniform1D(0, 1), bool quiet=false) |
Run a benchmark on a generic function, with the given argument options. More... | |
Variables | |
struct chebyshev::benchmark::benchmark_settings | settings |
struct chebyshev::benchmark::benchmark_results | results |
Benchmark module.
This module provides routines for measuring the average runtime of functions of any kind over a randomized or fixed vector of inputs. The benchmark::benchmark implements this functionality and registers the results for analysis and output.
|
inline |
Run a benchmark on a generic function, with the given options.
The result is registered inside results.benchmarkResults.
name | The name of the test case |
func | The function to benchmark |
opt | The benchmark options |
|
inline |
Run a benchmark on a generic function, with the given input vector.
The result is registered inside results.benchmarkResults.
name | The name of the test case |
func | The function to benchmark |
input | The vector of input values |
runs | The number of runs with the same input |
|
inline |
Run a benchmark on a generic function, with the given argument options.
The result is registered inside results.benchmarkResults.
name | The name of the test case |
func | The function to benchmark |
run | The number of runs with the same input |
iterations | The number of iterations of the function |
inputGenerator | The input generator to use |
|
inline |
Measure the total runtime of a function over the given input for a single run.
It is generally not needed to call this function directly, as benchmarks can be run and registered using benchmark::benchmark.
func | The function to measure the runtime of |
input | The vector of inputs |
|
inline |
Setup the benchmark environment.
moduleName | Name of the module under test. |
argc | The number of command line arguments |
argv | A list of C-style strings containing the command line arguments. |
|
inline |
Terminate the benchmarking environment.
If benchmarks have been run, their results will be printed.
exit | Whether to exit after terminating the module. |