HoverRace  2.0
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
HoverRace::Util::Profiler Class Reference

Simple profiler. More...

#include <Profiler.h>

Classes

struct  LapTime
 
class  Sampler
 

Public Types

using clock_t = std::chrono::high_resolution_clock
 
using dur_t = std::chrono::nanoseconds
 

Public Member Functions

 Profiler ()=delete
 
 Profiler (const std::string &name)
 
std::shared_ptr< ProfilerAddSub (const std::string &name)
 Add a new subset. More...
 
dur_t GetDuration () const
 
const LapTimeGetLastLap () const
 
const std::string & GetName () const
 
const LapTimeGetOtherTime () const
 Retrieve the unaccounted-for time from the last call to Lap(). More...
 
const LapTimeLap (const Profiler *parent=nullptr)
 Calculate the statistics for the current period, then reset the counters to start the next period. More...
 
void Reset ()
 Resets the accumulated time. More...
 

Private Attributes

dur_t dur
 
LapTime lap
 
std::string name
 
LapTime otherTime
 
clock_t::time_point sampleStart
 
int sampling
 
std::vector< std::shared_ptr< Profiler > > subs
 

Detailed Description

Simple profiler.

Author
Michael Imamura

Member Typedef Documentation

using HoverRace::Util::Profiler::clock_t = std::chrono::high_resolution_clock
using HoverRace::Util::Profiler::dur_t = std::chrono::nanoseconds

Constructor & Destructor Documentation

HoverRace::Util::Profiler::Profiler ( )
delete
HoverRace::Util::Profiler::Profiler ( const std::string &  name)

Member Function Documentation

std::shared_ptr< Profiler > HoverRace::Util::Profiler::AddSub ( const std::string &  name)

Add a new subset.

Parameters
nameThe name of the subset.
Returns
The created subset (never nullptr).
dur_t HoverRace::Util::Profiler::GetDuration ( ) const
inline
const LapTime& HoverRace::Util::Profiler::GetLastLap ( ) const
inline
const std::string& HoverRace::Util::Profiler::GetName ( ) const
inline
const LapTime& HoverRace::Util::Profiler::GetOtherTime ( ) const
inline

Retrieve the unaccounted-for time from the last call to Lap().

Returns
The other time.
const Profiler::LapTime & HoverRace::Util::Profiler::Lap ( const Profiler parent = nullptr)

Calculate the statistics for the current period, then reset the counters to start the next period.

Parameters
parentThe parent profiler (nullptr if this is the root profiler).
Returns
The lap statistics (also available via GetLastLap()).
void HoverRace::Util::Profiler::Reset ( )

Resets the accumulated time.

All subsets are also reset.

Member Data Documentation

dur_t HoverRace::Util::Profiler::dur
private
LapTime HoverRace::Util::Profiler::lap
private
std::string HoverRace::Util::Profiler::name
private
LapTime HoverRace::Util::Profiler::otherTime
private
clock_t::time_point HoverRace::Util::Profiler::sampleStart
private
int HoverRace::Util::Profiler::sampling
private
std::vector<std::shared_ptr<Profiler> > HoverRace::Util::Profiler::subs
private

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