Ocean
Ocean::HighPerformanceStatistic Class Reference

This class implements a simple module gathering high performance timer statistics. More...

Data Structures

class  ScopedStatistic
 This class defines a scoped high performance statistic module. More...
 

Public Types

typedef std::vector< double > Measurements
 Definition of a vector storing performance measurements. More...
 

Public Member Functions

 HighPerformanceStatistic ()
 Creates a new statistic module. More...
 
double first () const
 Returns the first measurement time in seconds. More...
 
double firstMseconds () const
 Returns the first measurement time in milliseconds. More...
 
double second () const
 Returns the second measurement time in seconds. More...
 
double secondMseconds () const
 Returns the second measurement time in milliseconds. More...
 
double best () const
 Returns the best measurement time in seconds. More...
 
double bestMseconds () const
 Returns the best measurement time in milliseconds. More...
 
double worst () const
 Returns the worst measurement time in seconds. More...
 
double worstMseconds () const
 Returns the worst measurement time in milliseconds. More...
 
double last () const
 Returns the last measurement time in seconds. More...
 
double lastMseconds () const
 Returns the last (most recent measurement time in milliseconds. More...
 
double average () const
 Returns the average measurement time in seconds. More...
 
double averageMseconds () const
 Returns the average measurement time in milliseconds. More...
 
double averageCyclesPerOperation (const double operations, const double clockRate=3800000000.0) const
 Returns the average number of CPU cycles needed for one operation. More...
 
double median () const
 Returns the median measurement time in seconds. More...
 
double medianMseconds () const
 Returns the median measurement time in milliseconds. More...
 
double percentile (double value) const
 Returns a specific percentile (e.g., P50 = median, P90, P95, etc.) measurement time in seconds. More...
 
double percentileMseconds (double value) const
 Returns a specific percentile (e.g., P50 = median, P90, P95, etc.) measurement time in milliseconds. More...
 
double total () const
 Returns the total measurement time in seconds. More...
 
double totalMseconds () const
 Returns the total measurement time in milliseconds. More...
 
double running () const
 Returns the current (still) running measurement time in seconds. More...
 
double runningMseconds () const
 Returns the current (still) running measurement time in milliseconds. More...
 
size_t measurements () const
 Returns the number of measurements. More...
 
bool isRunning () const
 Returns whether currently a measurement is running. More...
 
void start ()
 Starts a new measurement. More...
 
void startIf (const bool value)
 Starts a new measurement if the given value is True, otherwise nothing happens. More...
 
void stop ()
 Stops a measurement. More...
 
void stopIf (const bool value)
 Stops a measurement. More...
 
void skip ()
 Skips a started measurement. More...
 
void skipIf (const bool value)
 Skips a started measurement. More...
 
void reset ()
 Resets all gathered statistics. More...
 
std::string toString (const unsigned int precision=2u) const
 Returns a string with the relevant performance information of this statistic object. More...
 
 operator bool () const
 Returns whether at least one measurement has been done. More...
 
HighPerformanceStatisticoperator+= (const HighPerformanceStatistic &right)
 Adds measurements from another object to this statistic object. More...
 

Private Attributes

HighPerformanceTimer timer_
 High performance timer. More...
 
Measurements measurements_
 The individual measurements in order as measured. More...
 
double best_ = DBL_MAX
 Best measurement time in seconds. More...
 
double worst_ = -DBL_MAX
 Worst measurement time in seconds. More...
 
double total_ = 0.0
 Entire measurement time in seconds. More...
 
bool started_ = false
 State determining whether one measurement is active currently. More...
 

Detailed Description

This class implements a simple module gathering high performance timer statistics.

The class is not thread-safe.

Member Typedef Documentation

◆ Measurements

typedef std::vector<double> Ocean::HighPerformanceStatistic::Measurements

Definition of a vector storing performance measurements.

Constructor & Destructor Documentation

◆ HighPerformanceStatistic()

Ocean::HighPerformanceStatistic::HighPerformanceStatistic ( )

Creates a new statistic module.

Member Function Documentation

◆ average()

double Ocean::HighPerformanceStatistic::average ( ) const

Returns the average measurement time in seconds.

Returns
Average measurement time, in [sec]

◆ averageCyclesPerOperation()

double Ocean::HighPerformanceStatistic::averageCyclesPerOperation ( const double  operations,
const double  clockRate = 3800000000.0 
) const
inline

Returns the average number of CPU cycles needed for one operation.

Parameters
operationsThe number of operation that has been invoked during each measurement, with range [1, infinity)
clockRateThe number of clock cycles per second of the CPU, e.g., 3.8GHz, with range [1, infinity)
Returns
The average number of CPU cycles needed, with range (0, infinity), -1 if no valid measurement exists

◆ averageMseconds()

double Ocean::HighPerformanceStatistic::averageMseconds ( ) const
inline

Returns the average measurement time in milliseconds.

Returns
Average measurement time, in [ms]

◆ best()

double Ocean::HighPerformanceStatistic::best ( ) const
inline

Returns the best measurement time in seconds.

Returns
Best measurement time, in [sec]

◆ bestMseconds()

double Ocean::HighPerformanceStatistic::bestMseconds ( ) const
inline

Returns the best measurement time in milliseconds.

Returns
Best measurement time, in [ms]

◆ first()

double Ocean::HighPerformanceStatistic::first ( ) const
inline

Returns the first measurement time in seconds.

Returns
First measurement time, in [sec]

◆ firstMseconds()

double Ocean::HighPerformanceStatistic::firstMseconds ( ) const
inline

Returns the first measurement time in milliseconds.

Returns
First measurement time, in [ms]

◆ isRunning()

bool Ocean::HighPerformanceStatistic::isRunning ( ) const
inline

Returns whether currently a measurement is running.

Returns
True, if so

◆ last()

double Ocean::HighPerformanceStatistic::last ( ) const
inline

Returns the last measurement time in seconds.

Returns
Last measurement time, in [sec]

◆ lastMseconds()

double Ocean::HighPerformanceStatistic::lastMseconds ( ) const
inline

Returns the last (most recent measurement time in milliseconds.

Returns
Last measurement time, in [ms]

◆ measurements()

size_t Ocean::HighPerformanceStatistic::measurements ( ) const
inline

Returns the number of measurements.

Returns
Measurement numbers

◆ median()

double Ocean::HighPerformanceStatistic::median ( ) const

Returns the median measurement time in seconds.

Returns
Median measurement time, in [sec]

◆ medianMseconds()

double Ocean::HighPerformanceStatistic::medianMseconds ( ) const

Returns the median measurement time in milliseconds.

Returns
Median measurement time, in [ms]

◆ operator bool()

Ocean::HighPerformanceStatistic::operator bool ( ) const
inlineexplicit

Returns whether at least one measurement has been done.

Returns
True, if so

◆ operator+=()

HighPerformanceStatistic& Ocean::HighPerformanceStatistic::operator+= ( const HighPerformanceStatistic right)

Adds measurements from another object to this statistic object.

Parameters
rightThe statistic object of which the measurements will be added to this object
Returns
Reference to this object

◆ percentile()

double Ocean::HighPerformanceStatistic::percentile ( double  value) const

Returns a specific percentile (e.g., P50 = median, P90, P95, etc.) measurement time in seconds.

Parameters
valueThe percentile to be returned, with range [0, 1]
Returns
The measurement for the specified percentile, in seconds

◆ percentileMseconds()

double Ocean::HighPerformanceStatistic::percentileMseconds ( double  value) const

Returns a specific percentile (e.g., P50 = median, P90, P95, etc.) measurement time in milliseconds.

Parameters
valueThe percentile to be returned, with range [0, 1]
Returns
The measurement for the specified percentile, in milliseconds

◆ reset()

void Ocean::HighPerformanceStatistic::reset ( )

Resets all gathered statistics.

◆ running()

double Ocean::HighPerformanceStatistic::running ( ) const
inline

Returns the current (still) running measurement time in seconds.

Returns
Current still running measurement time, in [sec]

◆ runningMseconds()

double Ocean::HighPerformanceStatistic::runningMseconds ( ) const
inline

Returns the current (still) running measurement time in milliseconds.

Returns
Current still running measurement time, in [ms]

◆ second()

double Ocean::HighPerformanceStatistic::second ( ) const
inline

Returns the second measurement time in seconds.

Returns
Second measurement time, in [sec]

◆ secondMseconds()

double Ocean::HighPerformanceStatistic::secondMseconds ( ) const
inline

Returns the second measurement time in milliseconds.

Returns
Second measurement time, in [ms]

◆ skip()

void Ocean::HighPerformanceStatistic::skip ( )

Skips a started measurement.

The measurement will not be voted.

◆ skipIf()

void Ocean::HighPerformanceStatistic::skipIf ( const bool  value)

Skips a started measurement.

The measurement will not be voted.

Parameters
valueTrue; to skip the measurement; False, to ignore this call

◆ start()

void Ocean::HighPerformanceStatistic::start ( )

Starts a new measurement.

◆ startIf()

void Ocean::HighPerformanceStatistic::startIf ( const bool  value)

Starts a new measurement if the given value is True, otherwise nothing happens.

Parameters
valueTrue; to start a new measurement; False, to ignore this call

◆ stop()

void Ocean::HighPerformanceStatistic::stop ( )

Stops a measurement.

◆ stopIf()

void Ocean::HighPerformanceStatistic::stopIf ( const bool  value)

Stops a measurement.

Parameters
valueTrue; to stop the measurement; False, to ignore this call

◆ toString()

std::string Ocean::HighPerformanceStatistic::toString ( const unsigned int  precision = 2u) const

Returns a string with the relevant performance information of this statistic object.

Parameters
precisionThe number of decimal places displayed, with range [1, infinity)
Returns
The resulting string

◆ total()

double Ocean::HighPerformanceStatistic::total ( ) const
inline

Returns the total measurement time in seconds.

Returns
Total measurement time, in [sec]

◆ totalMseconds()

double Ocean::HighPerformanceStatistic::totalMseconds ( ) const
inline

Returns the total measurement time in milliseconds.

Returns
Total measurement time, in [ms]

◆ worst()

double Ocean::HighPerformanceStatistic::worst ( ) const
inline

Returns the worst measurement time in seconds.

Returns
Worst measurement time, in [sec]

◆ worstMseconds()

double Ocean::HighPerformanceStatistic::worstMseconds ( ) const
inline

Returns the worst measurement time in milliseconds.

Returns
Worst measurement time, in [ms]

Field Documentation

◆ best_

double Ocean::HighPerformanceStatistic::best_ = DBL_MAX
private

Best measurement time in seconds.

◆ measurements_

Measurements Ocean::HighPerformanceStatistic::measurements_
private

The individual measurements in order as measured.

◆ started_

bool Ocean::HighPerformanceStatistic::started_ = false
private

State determining whether one measurement is active currently.

◆ timer_

HighPerformanceTimer Ocean::HighPerformanceStatistic::timer_
private

High performance timer.

◆ total_

double Ocean::HighPerformanceStatistic::total_ = 0.0
private

Entire measurement time in seconds.

◆ worst_

double Ocean::HighPerformanceStatistic::worst_ = -DBL_MAX
private

Worst measurement time in seconds.


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