SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
InstrumentationTimer Class Reference

#include <Instrumentor.h>

Public Member Functions

 InstrumentationTimer (const char *name)
 
 ~InstrumentationTimer ()
 
void stop ()
 

Private Attributes

const char * _name
 function or scope name as char pointer (not std::string) More...
 
HighResTimePoint _startTimepoint
 start timepoint More...
 
bool _isStopped
 flag if timer got stopped More...
 

Detailed Description

Definition at line 189 of file Instrumentor.h.

Constructor & Destructor Documentation

◆ InstrumentationTimer()

InstrumentationTimer::InstrumentationTimer ( const char *  name)
inline

Definition at line 192 of file Instrumentor.h.

192  : _name(name), _isStopped(false)
193  {
194  _startTimepoint = std::chrono::high_resolution_clock::now();
195  }
bool _isStopped
flag if timer got stopped
Definition: Instrumentor.h:221
HighResTimePoint _startTimepoint
start timepoint
Definition: Instrumentor.h:220
const char * _name
function or scope name as char pointer (not std::string)
Definition: Instrumentor.h:219

◆ ~InstrumentationTimer()

InstrumentationTimer::~InstrumentationTimer ( )
inline

Definition at line 197 of file Instrumentor.h.

198  {
199  if (!_isStopped)
200  stop();
201  }

Member Function Documentation

◆ stop()

void InstrumentationTimer::stop ( )
inline

Definition at line 203 of file Instrumentor.h.

204  {
205  auto endTimepoint = std::chrono::high_resolution_clock::now();
206 
207  long long start = std::chrono::time_point_cast<std::chrono::microseconds>(_startTimepoint).time_since_epoch().count();
208  long long end = std::chrono::time_point_cast<std::chrono::microseconds>(endTimepoint).time_since_epoch().count();
209 
210  uint32_t threadID = (uint32_t)std::hash<std::thread::id>{}(std::this_thread::get_id());
211 
212  Instrumentor::get().addProfile({_name, start, end, threadID});
213 
214  _isStopped = true;
215  }
void addProfile(const ProfileResult &result)
Definition: Instrumentor.h:119
static Instrumentor & get()
Definition: Instrumentor.h:168

Member Data Documentation

◆ _isStopped

bool InstrumentationTimer::_isStopped
private

flag if timer got stopped

Definition at line 221 of file Instrumentor.h.

◆ _name

const char* InstrumentationTimer::_name
private

function or scope name as char pointer (not std::string)

Definition at line 219 of file Instrumentor.h.

◆ _startTimepoint

HighResTimePoint InstrumentationTimer::_startTimepoint
private

start timepoint

Definition at line 220 of file Instrumentor.h.


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