rambrain
tester Class Reference

A basic class to be used by tests. Provides helper methods and functionality e.g. time measurements. More...

#include <tester.h>

Public Member Functions

 tester (const char *name="")
 tester Create a new tester More...
 
 ~tester ()
 Cleans up and destroys the tester. More...
 
void addParameter (char *param)
 Add a new parameter to the list of parameters. More...
 
void addTimeMeasurement ()
 Saves the current timestamp. More...
 
void addExternalTime (std::chrono::duration< double >)
 Add a duration to the timing list. More...
 
void addComment (const char *comment)
 Simple setter. More...
 
void setSeed (unsigned int seed=time(NULL))
 Set a new seed for random number generation. More...
 
int random (int max) const
 Get a random number (integer) More...
 
uint64_t random (uint64_t max) const
 Get a random number (long integer) More...
 
double random (double max=1.0) const
 Get a random number (double) More...
 
void startNewTimeCycle ()
 Starts a new cycle of time measurements. More...
 
void startNewRNGCycle ()
 Starts a new cycle of random numbers. More...
 
void writeToFile ()
 Write all collected information to file. More...
 
std::vector< int64_t > getDurationsForCurrentCycle () const
 Take the current cycle of time measurements and calculate all durations in betwen. More...
 

Private Attributes

const char * name
 
std::vector< char * > parameters
 
std::vector< std::vector< std::chrono::high_resolution_clock::time_point > > timeMeasures
 
std::string comment
 
std::vector< unsigned int > seeds
 
std::vector< bool > seeded
 

Detailed Description

A basic class to be used by tests. Provides helper methods and functionality e.g. time measurements.

Definition at line 32 of file tester.h.

Constructor & Destructor Documentation

tester::tester ( const char *  name = "")

tester Create a new tester

Parameters
nameName of the current test

Definition at line 22 of file tester.cpp.

tester::~tester ( )

Cleans up and destroys the tester.

Definition at line 27 of file tester.cpp.

Member Function Documentation

void tester::addComment ( const char *  comment)

Simple setter.

Definition at line 59 of file tester.cpp.

void tester::addExternalTime ( std::chrono::duration< double >  )

Add a duration to the timing list.

Definition at line 45 of file tester.cpp.

void tester::addParameter ( char *  param)

Add a new parameter to the list of parameters.

Parameters
paramThe parameter value

Definition at line 31 of file tester.cpp.

void tester::addTimeMeasurement ( )

Saves the current timestamp.

Definition at line 36 of file tester.cpp.

std::vector< int64_t > tester::getDurationsForCurrentCycle ( ) const

Take the current cycle of time measurements and calculate all durations in betwen.

Returns
A list of durations with size of time measurements minus one

Definition at line 186 of file tester.cpp.

int tester::random ( int  max) const

Get a random number (integer)

Parameters
maxThe upper limit for generated random numbers
Returns
The number

Definition at line 74 of file tester.cpp.

uint64_t tester::random ( uint64_t  max) const

Get a random number (long integer)

Parameters
maxThe upper limit for generated random numbers
Returns
The number

Definition at line 79 of file tester.cpp.

double tester::random ( double  max = 1.0) const

Get a random number (double)

Parameters
maxThe upper limit for generated random numbers
Returns
The number

Definition at line 84 of file tester.cpp.

void tester::setSeed ( unsigned int  seed = time ( NULL ))

Set a new seed for random number generation.

Parameters
seedThe seed

Definition at line 64 of file tester.cpp.

void tester::startNewRNGCycle ( )

Starts a new cycle of random numbers.

Allows to set a new seed afterwards without loosing the seed information before

Definition at line 94 of file tester.cpp.

void tester::startNewTimeCycle ( )

Starts a new cycle of time measurements.

Different cycles are independent. In each cycle durations are measured w.r.t. the last measurement

Definition at line 89 of file tester.cpp.

void tester::writeToFile ( )

Write all collected information to file.

The file name consists of the test name followed by a hash seperated list of the parameter values

Definition at line 100 of file tester.cpp.

Member Data Documentation

std::string tester::comment
private

Definition at line 118 of file tester.h.

const char* tester::name
private

Definition at line 115 of file tester.h.

std::vector<char *> tester::parameters
private

Definition at line 116 of file tester.h.

std::vector<bool> tester::seeded
private

Definition at line 120 of file tester.h.

std::vector<unsigned int> tester::seeds
private

Definition at line 119 of file tester.h.

std::vector<std::vector<std::chrono::high_resolution_clock::time_point> > tester::timeMeasures
private

Definition at line 117 of file tester.h.


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