Chebyshev
Unit testing for scientific software
Loading...
Searching...
No Matches
chebyshev::benchmark Namespace Reference

Benchmark module. More...

Namespaces

namespace  generator
 Input generators for benchmarks.
 

Classes

class  benchmark_context
 Benchmark module context, handling benchmark requests concurrently. More...
 
class  benchmark_options
 A structure holding the options of a benchmark. More...
 
class  benchmark_result
 Structure holding the results of a benchmark. More...
 
class  benchmark_settings
 Global settings of the benchmark module, used in benchmark_context. More...
 
class  timer
 Timer class to measure elapsed time in milliseconds. More...
 

Typedefs

template<typename InputType >
using InputGenerator = std::function< InputType(random::random_source &)>
 A function which takes in a random source and returns a generated input element.
 

Functions

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.
 
benchmark_context make_context (const std::string &moduleName, int argc=0, const char **argv=nullptr)
 Construct a benchmarking context with the given parameters.
 

Detailed Description

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.

Function Documentation

◆ make_context()

benchmark_context chebyshev::benchmark::make_context ( const std::string &  moduleName,
int  argc = 0,
const char **  argv = nullptr 
)

Construct a benchmarking context with the given parameters.

Parameters
moduleNameName of the module under test.
argcThe number of command line arguments.
argvAn array of command line arguments as C-like strings.

◆ runtime()

long double chebyshev::benchmark::runtime ( Function  func,
const std::vector< InputType > &  input 
)
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.

Parameters
funcThe function to measure the runtime of
inputThe vector of inputs
Returns
The total runtime of the function over the input vector.