Celero
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
celero::TestFixture Class Reference

#include <TestFixture.h>

Inheritance diagram for celero::TestFixture:
Inheritance graph
[legend]

Classes

class  ExperimentValue
 You can derive from this type to add your own information to the experiment value set. More...
 

Public Types

enum  Constants : int64_t { NoProblemSpaceValue = std::numeric_limits<int64_t>::min() }
 

Public Member Functions

 TestFixture ()
 Default Constructor.
 
virtual ~TestFixture ()
 Virtual destructor for inheritance.
 
virtual std::vector< std::shared_ptr< celero::TestFixture::ExperimentValue > > getExperimentValues () const
 Allows a test fixture to supply values to use for experiments. More...
 
virtual double getExperimentValueResultScale () const
 Provide a units result scale of each experiment value. More...
 
virtual void onExperimentStart (const celero::TestFixture::ExperimentValue *const x)
 Allows the text fixture to run code that will be executed once immediately before the benchmark. More...
 
virtual void onExperimentEnd ()
 Allows the text fixture to run code that will be executed once immediately after the benchmark. More...
 
virtual void setUp (const celero::TestFixture::ExperimentValue *const x)
 Set up the test fixture before benchmark execution. More...
 
void setExperimentTime (uint64_t x)
 Internal to Celero.
 
uint64_t getExperimentTime () const
 Valid inside tearDown().
 
void setExperimentIterations (uint64_t x)
 Internal to Celero.
 
uint64_t getExperimentIterations () const
 Valid inside tearDown().
 
virtual void tearDown ()
 Called after test completion to destroy the fixture. More...
 
virtual uint64_t run (uint64_t threads, uint64_t iterations, const celero::TestFixture::ExperimentValue *const experimentValue)
 
virtual std::vector< std::shared_ptr< UserDefinedMeasurement > > getUserDefinedMeasurements () const
 If you want to use user-defined measurements, override this method to return them. More...
 
std::vector< std::string > getUserDefinedMeasurementNames () const
 Returns the names of all user-defined measurements in this fixture.
 

Protected Member Functions

virtual void UserBenchmark ()
 Executed for each operation the benchmarking test is run.
 
virtual uint64_t HardCodedMeasurement () const
 Only used for baseline cases. More...
 

Detailed Description

Author
John Farrier

Member Function Documentation

◆ getExperimentValueResultScale()

virtual double celero::TestFixture::getExperimentValueResultScale ( ) const
inlinevirtual

Provide a units result scale of each experiment value.

If the value is greater than 0 then additional statistic value will be printed in output - [ xxxx units/sec ]. For example for measure speed of file IO operations method might return 1024 * 1024 to get megabytes per second.

It is only guaranteed that the constructor is called prior to this function being called.

Reimplemented in BaseFixture.

◆ getExperimentValues()

virtual std::vector<std::shared_ptr<celero::TestFixture::ExperimentValue> > celero::TestFixture::getExperimentValues ( ) const
inlinevirtual

Allows a test fixture to supply values to use for experiments.

This is used to create multiple runs of the same experiment and varrying the data set size, for example. The second value of the pair is an optional override for the number of iterations to be used. If zero is specified, then the default number of iterations is used.

It is only guaranteed that the constructor is called prior to this function being called.

Reimplemented in SortFixture, CompressBoolsFixture, DemoTransformFixture, SortFixture, ParticlesFixture, and BaseFixture.

◆ getUserDefinedMeasurements()

std::vector< std::shared_ptr< UserDefinedMeasurement > > TestFixture::getUserDefinedMeasurements ( ) const
virtual

If you want to use user-defined measurements, override this method to return them.

This method must return a vector of pointers, one per type of user-defined measurement that you want to measure.

Reimplemented in SortFixture.

◆ HardCodedMeasurement()

uint64_t TestFixture::HardCodedMeasurement ( ) const
protectedvirtual

Only used for baseline cases.

Used to define a hard-coded execution time vs. actually making a measurement.

◆ onExperimentEnd()

void TestFixture::onExperimentEnd ( )
virtual

Allows the text fixture to run code that will be executed once immediately after the benchmark.

Unlike tearDown, the evaluation of this function IS included in the total experiment execution time.

Reimplemented in SortFixture, and SortFixture.

◆ onExperimentStart()

void TestFixture::onExperimentStart ( const celero::TestFixture::ExperimentValue *const  x)
virtual

Allows the text fixture to run code that will be executed once immediately before the benchmark.

Unlike setUp, the evaluation of this function IS included in the total experiment execution time.

Parameters
xThe value for the experiment. This can be ignored if the test does not utilize experiment values.

Reimplemented in SortFixture, and SortFixture.

◆ run()

uint64_t TestFixture::run ( uint64_t  threads,
uint64_t  iterations,
const celero::TestFixture::ExperimentValue *const  experimentValue 
)
virtual
Parameters
threadsThe number of working threads.
iterationsThe number of times to loop over the UserBenchmark function.
experimentValueThe experiment value to pass in setUp function.
Returns
Returns the number of microseconds the run took.

Reimplemented in celero::ThreadTestFixture.

◆ setUp()

void TestFixture::setUp ( const celero::TestFixture::ExperimentValue *const  x)
virtual

Set up the test fixture before benchmark execution.

This code is NOT included in the benchmark timing. It is executed once before all iterations are executed and between each Sample. Your experiment should NOT rely on "setUp" methods to be called before EACH experiment run, only between each sample.

Parameters
xThe celero::TestFixture::ExperimentValue for the experiment. This can be ignored if the test does not utilize experiment values.

Reimplemented in SimdVersionFixture, PackedStructFixture, ManualVersionFixture, SortFixture, StdVectorFixture, NoPackingFixture, ParticlesPtrVectorFixture, CompressBoolsFixture, DemoTransformFixture, SortFixture, StdFileFixture, MutexFixture, ParticlesObjVectorFixture, BaseFixture, AtomicFixture, and BaseFixture.

◆ tearDown()

void TestFixture::tearDown ( )
virtual

Called after test completion to destroy the fixture.

This code is NOT included in the benchmark timing. It is executed once after all iterations are executed and between each Sample. Your experiment should NOT rely on "tearDown" methods to be called after EACH experiment run, only between each sample.

Reimplemented in SimdVersionFixture, PackedStructFixture, ManualVersionFixture, SortFixture, StdVectorFixture, StdBitsetFixture, NoPackingFixture, ParticlesPtrVectorFixture, DemoTransformFixture, SortFixture, StdFileFixture, ParticlesObjVectorFixture, and BaseFixture.


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