OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Public Member Functions | List of all members
InternalZGY::SimpleTimer Class Reference

Timer that knows where to store the result. More...

#include <timer.h>

Inheritance diagram for InternalZGY::SimpleTimer:
InternalZGY::Timer

Public Member Functions

 SimpleTimer (SummaryTimer &owner, bool enabled=true)
 
- Public Member Functions inherited from InternalZGY::Timer
 Timer (bool enable=true, const char *name=0, int skip=0, bool startrunning=true)
 
bool getEnabled () const
 
double getFrequency () const
 
double getLast () const
 
double getTotal () const
 
double getOverhead () const
 
int getCount () const
 
const char * getName () const
 
int getSkip () const
 
bool getRunning () const
 
int getVerbose () const
 
const char * getValue (bool details=false, bool msonly=false)
 
void setVerbose (int v)
 
void start ()
 
void stop ()
 
void reset ()
 

Additional Inherited Members

- Static Public Member Functions inherited from InternalZGY::Timer
static void getValue_s (char *buf, int len, const char *name, int count, double total, bool running, bool details, bool msonly)
 

Detailed Description

Timer that knows where to store the result.

SimpleTimer is normally short lived. The SimpleTimer constructor takes a SummaryTimer as an argument. When the SimpleTimer goes out of scope the result is added to the accumulate timer. The caller is responsible for not allowing the SummaryTimer to go out of scope before the SimpleTimer does.

There is also a SummaryPrintingTimer class that extends SummaryTimer to print a single line report when it goes out of scope.

Note that Timer and SimpleTimer are not designed to be threadsafe. This makes no sense when measuring a single piece of code execution. SummaryTimer::add() is threadsafe. This means the following example with the SummaryTimer being shared among threads will work. The example measures every execution of the function and prints a report on application exit.

void SomeFunction() {
static SummaryPrintingTimer pt("MyTimer");
SimpleTimer tt(pt);
// timing the following code...
}

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