HIPO  4.3.0
High Performance Output data format for experimental physics
hipo::benchmark Class Reference

Simple timer for measuring code performance. More...

#include <utils.h>

Public Member Functions

 benchmark (const char *name)
 Constructs a benchmark with the given name. More...
 
 benchmark ()
 Default constructor. More...
 
 benchmark (int freq)
 Constructs a benchmark with automatic printout frequency. More...
 
 ~benchmark ()
 Destructor. More...
 
void reset ()
 Resets accumulated time and counter to zero. More...
 
void setName (const char *name)
 Sets the display name of this benchmark. More...
 
void resume ()
 Starts or resumes the timer. More...
 
void pause ()
 Pauses the timer and accumulates elapsed time. More...
 
long getTime ()
 Returns the accumulated time in microseconds. More...
 
double getTimeSec ()
 Returns the accumulated time in seconds. More...
 
int getCounter ()
 Returns the number of resume/pause cycles recorded. More...
 
void show ()
 Prints the benchmark name, accumulated time, and counter. More...
 

Detailed Description

Simple timer for measuring code performance.

Accumulates elapsed time across multiple resume/pause cycles and tracks the number of timing intervals recorded.

Definition at line 157 of file utils.h.

Constructor & Destructor Documentation

◆ benchmark() [1/3]

hipo::benchmark::benchmark ( const char *  name)
inline

Constructs a benchmark with the given name.

Parameters
nameDisplay name for this benchmark.

Definition at line 174 of file utils.h.

◆ benchmark() [2/3]

hipo::benchmark::benchmark ( )
inline

Default constructor.

Definition at line 180 of file utils.h.

◆ benchmark() [3/3]

hipo::benchmark::benchmark ( int  freq)
inline

Constructs a benchmark with automatic printout frequency.

Parameters
freqNumber of pause() calls between automatic printouts.

Definition at line 186 of file utils.h.

◆ ~benchmark()

hipo::benchmark::~benchmark ( )
inline

Destructor.

Definition at line 189 of file utils.h.

Member Function Documentation

◆ getCounter()

int hipo::benchmark::getCounter ( )

Returns the number of resume/pause cycles recorded.

Definition at line 223 of file utils.cpp.

◆ getTime()

long hipo::benchmark::getTime ( )

Returns the accumulated time in microseconds.

Definition at line 215 of file utils.cpp.

◆ getTimeSec()

double hipo::benchmark::getTimeSec ( )

Returns the accumulated time in seconds.

Definition at line 219 of file utils.cpp.

◆ pause()

void hipo::benchmark::pause ( )

Pauses the timer and accumulates elapsed time.

Definition at line 206 of file utils.cpp.

◆ reset()

void hipo::benchmark::reset ( )
inline

Resets accumulated time and counter to zero.

Definition at line 192 of file utils.h.

◆ resume()

void hipo::benchmark::resume ( )

Starts or resumes the timer.

Definition at line 196 of file utils.cpp.

◆ setName()

void hipo::benchmark::setName ( const char *  name)
inline

Sets the display name of this benchmark.

Parameters
nameThe new name.

Definition at line 198 of file utils.h.

◆ show()

void hipo::benchmark::show ( )

Prints the benchmark name, accumulated time, and counter.

Definition at line 202 of file utils.cpp.


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