Leviathan  0.8.0.0
Leviathan game engine
Leviathan::TimingMonitor Class Reference

#include <TimingMonitor.h>

Static Public Member Functions

static DLLEXPORT void StartTiming (const std::string &name, int style=TIMINGMONITOR_STYLE_RESULT_DEFAULT)
 
static DLLEXPORT int GetCurrentElapsed (const std::string &name)
 
static DLLEXPORT int StopTiming (const std::string &name, bool printoutput=true)
 
static DLLEXPORT size_t GetCurrentTimerCount ()
 
static DLLEXPORT void ClearTimers ()
 

Detailed Description

Definition at line 39 of file TimingMonitor.h.

Member Function Documentation

◆ ClearTimers()

DLLEXPORT void Leviathan::TimingMonitor::ClearTimers ( )
static

Definition at line 65 of file TimingMonitor.cpp.

65  {
66 
67  for(size_t i = 0; i < Timers.size(); i++){
68  if(i == 0)
69  Logger::Get()->Info("TimingMonitor: leaked timers! names:");
70  Logger::Get()->Write(Timers[i]->Name);
71  }
72  // just clear all timers vector and they will delete automatically //
73  Timers.clear();
74 }
DLLEXPORT void Write(const std::string &data) override
Definition: Logger.cpp:113
DLLEXPORT void Info(const std::string &data) override
Definition: Logger.cpp:164
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106

◆ GetCurrentElapsed()

int Leviathan::TimingMonitor::GetCurrentElapsed ( const std::string &  name)
static

Definition at line 16 of file TimingMonitor.cpp.

16  {
17  // loop through timers and get right based on name //
18  for(unsigned int i = 0; i < Timers.size(); i++){
19  if(Timers[i]->Name == name){
20  // "end" the timer and return it's result which is the elapsed time //
21  return Timers[i]->EndMonitoring();
22  }
23  }
24  return -1;
25 }

◆ GetCurrentTimerCount()

size_t Leviathan::TimingMonitor::GetCurrentTimerCount ( )
static

Definition at line 53 of file TimingMonitor.cpp.

53  {
54  return Timers.size();
55 }

◆ StartTiming()

void Leviathan::TimingMonitor::StartTiming ( const std::string &  name,
int  style = TIMINGMONITOR_STYLE_RESULT_DEFAULT 
)
static

Definition at line 10 of file TimingMonitor.cpp.

12 {
13  Timers.push_back(shared_ptr<TimingMonitorClock>(new TimingMonitorClock(name, style)));
14 }

◆ StopTiming()

int Leviathan::TimingMonitor::StopTiming ( const std::string &  name,
bool  printoutput = true 
)
static

Definition at line 27 of file TimingMonitor.cpp.

27  {
28 
29  // loop through timers and get right based on name //
30  for(size_t i = 0; i < Timers.size(); i++){
31  if(Timers[i]->Name == name){
32  // "end" the timer and return it's result which is the elapsed time //
33  // if specified print to log //
34  int time = Timers[i]->EndMonitoring();
35 
36  if(printoutput){
37  Logger::Get()->Info("TimingMonitor: Timer \""+name+
38  "\" stopped elapsed "+Convert::ToString(time/1000000.f)+" s ("+
39  Convert::ToString(time)+" micro seconds)");
40  }
41 
42  // remove the timer because memory might be filled with stuff //
43  // smart pointer //
44  Timers.erase(Timers.begin()+i);
45 
46  return time;
47  }
48  }
49 
50  return -1;
51 }
DLLEXPORT void Info(const std::string &data) override
Definition: Logger.cpp:164
static std::string ToString(const T &val)
Definition: Convert.h:72
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106

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