Electroneum
tools::PerformanceTimer Class Reference

#include <perf_timer.h>

Inheritance diagram for tools::PerformanceTimer:

Public Member Functions

 PerformanceTimer (bool paused=false)
 
 ~PerformanceTimer ()
 
void pause ()
 
void resume ()
 
void reset ()
 
uint64_t value () const
 
 operator uint64_t () const
 

Protected Attributes

uint64_t ticks
 
bool started
 
bool paused
 

Detailed Description

Definition at line 48 of file perf_timer.h.

Constructor & Destructor Documentation

◆ PerformanceTimer()

tools::PerformanceTimer::PerformanceTimer ( bool  paused = false)

Definition at line 107 of file perf_timer.cpp.

107  : started(true), paused(paused)
108 {
109  if (paused)
110  ticks = 0;
111  else
112  ticks = get_tick_count();
113 }
uint64_t get_tick_count()
Definition: perf_timer.cpp:46
Here is the call graph for this function:

◆ ~PerformanceTimer()

tools::PerformanceTimer::~PerformanceTimer ( )

Definition at line 141 of file perf_timer.cpp.

142 {
143  if (!paused)
144  ticks = get_tick_count() - ticks;
145 }
uint64_t get_tick_count()
Definition: perf_timer.cpp:46
Here is the call graph for this function:

Member Function Documentation

◆ operator uint64_t()

tools::PerformanceTimer::operator uint64_t ( ) const
inline

Definition at line 57 of file perf_timer.h.

57 { return value(); }
uint64_t value() const
Definition: perf_timer.cpp:190
Here is the call graph for this function:

◆ pause()

void tools::PerformanceTimer::pause ( )

Definition at line 166 of file perf_timer.cpp.

167 {
168  if (paused)
169  return;
170  ticks = get_tick_count() - ticks;
171  paused = true;
172 }
uint64_t get_tick_count()
Definition: perf_timer.cpp:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void tools::PerformanceTimer::reset ( )

Definition at line 182 of file perf_timer.cpp.

183 {
184  if (paused)
185  ticks = 0;
186  else
187  ticks = get_tick_count();
188 }
uint64_t get_tick_count()
Definition: perf_timer.cpp:46
Here is the call graph for this function:

◆ resume()

void tools::PerformanceTimer::resume ( )

Definition at line 174 of file perf_timer.cpp.

175 {
176  if (!paused)
177  return;
178  ticks = get_tick_count() - ticks;
179  paused = false;
180 }
uint64_t get_tick_count()
Definition: perf_timer.cpp:46
Here is the call graph for this function:

◆ value()

uint64_t tools::PerformanceTimer::value ( void  ) const

Definition at line 190 of file perf_timer.cpp.

191 {
192  uint64_t v = ticks;
193  if (!paused)
194  v = get_tick_count() - v;
195  return ticks_to_ns(v);
196 }
unsigned __int64 uint64_t
Definition: stdint.h:136
uint64_t ticks_to_ns(uint64_t ticks)
Definition: perf_timer.cpp:79
uint64_t get_tick_count()
Definition: perf_timer.cpp:46
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ paused

bool tools::PerformanceTimer::paused
protected

Definition at line 62 of file perf_timer.h.

◆ started

bool tools::PerformanceTimer::started
protected

Definition at line 61 of file perf_timer.h.

◆ ticks

uint64_t tools::PerformanceTimer::ticks
protected

Definition at line 60 of file perf_timer.h.


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