VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tklb::SectionTimer Class Reference

#include <TTimer.hpp>

Collaboration diagram for tklb::SectionTimer:

Public Types

enum  Unit { Miliseconds , Microseconds , Nanoseconds }
 

Public Member Functions

 SectionTimer (const char *message="", Unit unit=Microseconds, size_t divider=1)
 
 ~SectionTimer ()
 

Static Public Member Functions

static Time current ()
 
static size_t getMsSince (const Time &t)
 
static size_t getUsSince (const Time &t)
 
static size_t getNsSince (const Time &t)
 

Public Attributes

enum tklb::SectionTimer::Unit mUnit
 

Private Types

using Time = std::chrono::time_point< std::chrono::steady_clock >
 

Private Attributes

const char * mMessage
 
size_t mDivider
 
Time mStart
 

Detailed Description

Definition at line 12 of file TTimer.hpp.

Member Typedef Documentation

◆ Time

using tklb::SectionTimer::Time = std::chrono::time_point<std::chrono::steady_clock>
private

Definition at line 25 of file TTimer.hpp.

Member Enumeration Documentation

◆ Unit

Enumerator
Miliseconds 
Microseconds 
Nanoseconds 

Definition at line 14 of file TTimer.hpp.

14 {
18 } mUnit;
enum tklb::SectionTimer::Unit mUnit

Constructor & Destructor Documentation

◆ SectionTimer()

tklb::SectionTimer::SectionTimer ( const char *  message = "",
Unit  unit = Microseconds,
size_t  divider = 1 
)
inline

Definition at line 47 of file TTimer.hpp.

47 {
48 mMessage = message;
49 mUnit = unit;
50 mDivider = divider;
51 mStart = current();
52 }
const char * mMessage
Definition: TTimer.hpp:21
static Time current()
Definition: TTimer.hpp:31
Here is the call graph for this function:

◆ ~SectionTimer()

tklb::SectionTimer::~SectionTimer ( )
inline

Definition at line 54 of file TTimer.hpp.

54 {
55 if(mUnit == Nanoseconds) {
56 TKLB_PRINT("%s\t%zu\tnanoseconds\n", mMessage, getNsSince(mStart) / mDivider)
57 }
58 if (mUnit == Microseconds) {
59 TKLB_PRINT("%s\t%zu\tmicroseconds\n", mMessage, getUsSince(mStart) / mDivider)
60 }
61 if (mUnit == Miliseconds) {
62 TKLB_PRINT("%s\t%zu\tmilliseconds\n", mMessage, getMsSince(mStart) / mDivider)
63 }
64 }
#define TKLB_PRINT(...)
Definition: TPrint.h:4
static size_t getMsSince(const Time &t)
Definition: TTimer.hpp:35
static size_t getUsSince(const Time &t)
Definition: TTimer.hpp:39
static size_t getNsSince(const Time &t)
Definition: TTimer.hpp:43
Here is the call graph for this function:

Member Function Documentation

◆ current()

static Time tklb::SectionTimer::current ( )
inlinestatic

Definition at line 31 of file TTimer.hpp.

31 {
32 return std::chrono::steady_clock::now();
33 }
Here is the caller graph for this function:

◆ getMsSince()

static size_t tklb::SectionTimer::getMsSince ( const Time t)
inlinestatic

Definition at line 35 of file TTimer.hpp.

35 {
36 return std::chrono::duration_cast<std::chrono::milliseconds>(current() - t).count();
37 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNsSince()

static size_t tklb::SectionTimer::getNsSince ( const Time t)
inlinestatic

Definition at line 43 of file TTimer.hpp.

43 {
44 return std::chrono::duration_cast<std::chrono::nanoseconds>(current() - t).count();
45 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUsSince()

static size_t tklb::SectionTimer::getUsSince ( const Time t)
inlinestatic

Definition at line 39 of file TTimer.hpp.

39 {
40 return std::chrono::duration_cast<std::chrono::microseconds>(current() - t).count();
41 }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mDivider

size_t tklb::SectionTimer::mDivider
private

Definition at line 23 of file TTimer.hpp.

◆ mMessage

const char* tklb::SectionTimer::mMessage
private

Definition at line 21 of file TTimer.hpp.

◆ mStart

Time tklb::SectionTimer::mStart
private

Definition at line 27 of file TTimer.hpp.

◆ mUnit

enum tklb::SectionTimer::Unit tklb::SectionTimer::mUnit

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