Public Member Functions

Benchmark< S > Class Template Reference

The benchmark class. More...

#include <Benchmark.hpp>

List of all members.

Public Member Functions

 Benchmark (std::string n)
void setValue (S val)
 Set the value for the benchmark.
getValue () const
 Get the value for the current run of the benchmark.
virtual void preBench ()
 The pre benchmark task.
virtual void bench ()=0
 the benchmark function.
virtual void postBench ()
 the post benchmark function.
std::string getName () const
 Get the name of the benchmark.
void setName (std::string n)
 Set the name of the benchmark.
BenchResult run (unsigned repeats, unsigned warmup)
 run the benchmark.

Detailed Description

template<typename S>
class Benchmark< S >

The benchmark class.

All benchmarks using this framework should inherit from this base class.


Member Function Documentation

template<typename S>
virtual void Benchmark< S >::bench (  ) [pure virtual]

the benchmark function.

This is the function that is timed when running the benchmark.

template<typename S>
std::string Benchmark< S >::getName (  ) const [inline]

Get the name of the benchmark.

Returns:
std::string the name of the benchmark.
template<typename S>
S Benchmark< S >::getValue (  ) const [inline]

Get the value for the current run of the benchmark.

Returns:
the value

The value could potentially be updated before each time the bench function is called. This function is the correct way to get the current value to use as input to the benchmark.

template<typename S>
virtual void Benchmark< S >::postBench (  ) [inline, virtual]

the post benchmark function.

This should take care of any cleanup required for the benchmark to be run again. It should return the benchmark back to its original state, as the same benchmark object will be used for multiple runs.

template<typename S>
virtual void Benchmark< S >::preBench (  ) [inline, virtual]

The pre benchmark task.

Returns:
virtual void

Sometimes benchmarks require tasks to be done before the code that you're interested in benchmarking. This is the place to take care of that. The runtime if this function will not be included in the total benchmark runtime.

template<typename S >
BenchResult Benchmark< S >::run ( unsigned  repeats,
unsigned  warmup 
)

run the benchmark.

Parameters:
repeatsThe number of times to repeat the benchmark.
warmupThe number of times to run the benchmark before beginning timing.
Returns:
BenchResult The results from running the benchmark.

Run this benchmark the number of times given by repeats. After it's done running, it will find the average runtime and the standard deviation of the runtimes. The information will be returned in a BenchResult object.

template<typename S>
void Benchmark< S >::setName ( std::string  n ) [inline]

Set the name of the benchmark.

Parameters:
nstd::string the name.
template<typename S>
void Benchmark< S >::setValue ( val ) [inline]

Set the value for the benchmark.

Parameters:
valS the value.

This can really be anything, but should be able to be taken as input to the std::stringstream left-shift operator.


The documentation for this class was generated from the following file: