An open source method of characteristics neutron transport code.
Timer Class Reference

The Timer class is for timing and profiling regions of code. More...

#include "src/Timer.cpp"

Public Member Functions

 Timer ()
 Constructor sets the current split elapsed time to zero.
 
virtual ~Timer ()
 Destructor.
 
void startTimer ()
 Starts the Timer. More...
 
void stopTimer ()
 Stops the Timer. More...
 
void recordSplit (const char *msg)
 Records a message corresponding to a time for the current split. More...
 
double getTime ()
 Returns the time elapsed from startTimer() to stopTimer(). More...
 
double getSplit (const char *msg)
 Returns the time associated with a particular split. More...
 
void printSplits ()
 Prints the times and messages for each split to the console. More...
 
void clearSplit (const char *msg)
 Clears the time split for this message and deletes the message's entry in the Timer's splits log. More...
 
void clearSplits ()
 Clears all times split messages from the Timer.
 
void processMemUsage (double &vm_usage, double &resident_set)
 Read memory usage file (on a HPC installation), and process it to make it more readable. Used for profiling. More...
 

Static Public Member Functions

static TimerGet ()
 Returns a static instance of the Timer class. More...
 

Detailed Description

The Timer class is for timing and profiling regions of code.

Member Function Documentation

◆ clearSplit()

void Timer::clearSplit ( const char *  msg)

Clears the time split for this message and deletes the message's entry in the Timer's splits log.

Parameters
msgthe message tag for the split

◆ Get()

static Timer* Timer::Get ( )
inlinestatic

Returns a static instance of the Timer class.

Returns
a pointer to the static Timer class

◆ getSplit()

double Timer::getSplit ( const char *  msg)

Returns the time associated with a particular split.

If the split does not exist, returns 0.

Parameters
msgthe message tag for the split
Returns
the time recorded for the split (seconds)

◆ getTime()

double Timer::getTime ( )

Returns the time elapsed from startTimer() to stopTimer().

Returns
the elapsed time in seconds

◆ printSplits()

void Timer::printSplits ( )

Prints the times and messages for each split to the console.

This method will loop through all of the Timer's splits and print a formatted message string (80 characters in length) to the console with the message and the time corresponding to that message.

◆ processMemUsage()

void Timer::processMemUsage ( double &  vm_usage,
double &  resident_set 
)

Read memory usage file (on a HPC installation), and process it to make it more readable. Used for profiling.

Parameters
vm_usagetotal use of virtual memory
resident_settotal use of resident memory

◆ recordSplit()

void Timer::recordSplit ( const char *  msg)

Records a message corresponding to a time for the current split.

When this method is called it assumes that the Timer has been stopped and has the current time for the process corresponding to the message.

Parameters
msga msg corresponding to this time split

◆ startTimer()

void Timer::startTimer ( )

Starts the Timer.

This method is similar to starting a stopwatch.

◆ stopTimer()

void Timer::stopTimer ( )

Stops the Timer.

This method is similar to stopping a stopwatch.


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