hemocell
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
hemo::Profiler Class Reference

#include <profiler.h>

Collaboration diagram for hemo::Profiler:
Collaboration graph
[legend]

Public Member Functions

 Profiler (std::string name_)
 
 Profiler (std::string name_, Profiler &parent_)
 
void start ()
 
void stop ()
 
void reset ()
 
void printStatistics ()
 
void outputStatistics ()
 
void outputStatistics (int)
 
std::chrono::high_resolution_clock::duration elapsed ()
 
std::string elapsed_string ()
 
Profileroperator[] (std::string)
 
ProfilergetCurrent ()
 

Static Public Member Functions

static std::string toString (std::chrono::high_resolution_clock::duration)
 

Private Member Functions

void stop_nowarn ()
 
template<typename T >
void printStatistics_inner (int level, T &out)
 
template<typename T >
void printStatistics_JSON (T &out)
 

Private Attributes

std::chrono::high_resolution_clock::duration total_time = std::chrono::high_resolution_clock::duration::zero()
 
std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now()
 
bool started = false
 
const std::string name
 
std::map< std::string, Profilertimers
 
Profilerparent
 
Profilercurrent = this
 

Detailed Description

Profiler is a class that can be used to track (wall clock) time spent between start and stop invocations. Start and stop can be invoked multiple times per object.

Profiler supports hierarchy, with the [string] operator you can start or retrieve subtimers.

Profiler has a getCurrent() function which can be used to retrieve the last started (sub)timer. With this functionality you can time a function which is called through different paths as different functions in the hierarchy.

Constructor & Destructor Documentation

◆ Profiler() [1/2]

hemo::Profiler::Profiler ( std::string  name_)

◆ Profiler() [2/2]

hemo::Profiler::Profiler ( std::string  name_,
Profiler parent_ 
)

Member Function Documentation

◆ elapsed()

std::chrono::high_resolution_clock::duration hemo::Profiler::elapsed ( )

◆ elapsed_string()

std::string hemo::Profiler::elapsed_string ( )

◆ getCurrent()

Profiler & hemo::Profiler::getCurrent ( )

◆ operator[]()

Profiler & hemo::Profiler::operator[] ( std::string  name)

◆ outputStatistics() [1/2]

void hemo::Profiler::outputStatistics ( )

◆ outputStatistics() [2/2]

void hemo::Profiler::outputStatistics ( int  batchsize = INT_MAX)

◆ printStatistics()

void hemo::Profiler::printStatistics ( )

◆ printStatistics_inner()

template<typename T >
void hemo::Profiler::printStatistics_inner ( int  level,
T out 
)
private

◆ printStatistics_JSON()

template<typename T >
void hemo::Profiler::printStatistics_JSON ( T out)
private

◆ reset()

void hemo::Profiler::reset ( )

◆ start()

void hemo::Profiler::start ( )

◆ stop()

void hemo::Profiler::stop ( )

◆ stop_nowarn()

void hemo::Profiler::stop_nowarn ( )
private

◆ toString()

std::string hemo::Profiler::toString ( std::chrono::high_resolution_clock::duration  time)
static

Member Data Documentation

◆ current

Profiler* hemo::Profiler::current = this
private

◆ name

const std::string hemo::Profiler::name
private

◆ parent

Profiler& hemo::Profiler::parent
private

◆ start_time

std::chrono::high_resolution_clock::time_point hemo::Profiler::start_time = std::chrono::high_resolution_clock::now()
private

◆ started

bool hemo::Profiler::started = false
private

◆ timers

std::map<std::string,Profiler> hemo::Profiler::timers
private

◆ total_time

std::chrono::high_resolution_clock::duration hemo::Profiler::total_time = std::chrono::high_resolution_clock::duration::zero()
private