NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType > Class Template Reference

Util class to measure the time of NES components and sub-components using snapshots. More...

#include <Timer.hpp>

Classes

class  Snapshot
 

Public Member Functions

 Timer (std::string componentName)
 
void start ()
 starts the timer or resumes it after a pause More...
 
void pause ()
 pauses the timer More...
 
std::string createFullyQualifiedSnapShotName (const std::string &snapshotName)
 Creates a fully qualified name (how it is stored) More...
 
void snapshot (std::string snapshotName)
 saves current runtime as a snapshot. Useful for measuring the time of sub-components. More...
 
void merge (Timer timer)
 includes snapshots of another timer instance into this instance and adds overall runtime. More...
 
const std::vector< Snapshot > & getSnapshots () const
 returns the currently saved snapshots More...
 
int64_t getRuntimeFromSnapshot (const std::string &snapShotName)
 Returns the runtime of the snapshot with the snapShotName. More...
 
int64_t getRuntime () const
 returns the current runtime More...
 
const std::string & getComponentName () const
 returns the component name to measure More...
 
template<typename ConvertUnit = PrintTimeUnit, typename ConvertPrecision = PrintTimePrecision>
ConvertPrecision getPrintTime () const
 return timer runtime converted ConvertUnit with ConvertPrecision e.g. for printing purposes. More...
 

Static Public Member Functions

static std::string printHelper (std::string str, Snapshot s)
 helper function for insert string operator recursively goes through the (probably) nested snapshots and prints them More...
 
template<typename ConvertUnit = PrintTimeUnit>
static std::string getTimeUnitString ()
 helper function to return a time unit literal string based on PrintTimeUnit More...
 

Friends

std::ostream & operator<< (std::ostream &str, const Timer &t)
 overwrites insert string operator More...
 

Detailed Description

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
class NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >

Util class to measure the time of NES components and sub-components using snapshots.

Constructor & Destructor Documentation

◆ Timer()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::Timer ( std::string  componentName)
inline

Member Function Documentation

◆ createFullyQualifiedSnapShotName()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
std::string NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::createFullyQualifiedSnapShotName ( const std::string &  snapshotName)
inline

Creates a fully qualified name (how it is stored)

Parameters
snapshotName
Returns
Fully qualified name as string

Referenced by NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::snapshot().

Here is the caller graph for this function:

◆ getComponentName()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
const std::string& NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getComponentName ( ) const
inline

returns the component name to measure

Referenced by NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::merge().

Here is the caller graph for this function:

◆ getPrintTime()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
template<typename ConvertUnit = PrintTimeUnit, typename ConvertPrecision = PrintTimePrecision>
ConvertPrecision NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getPrintTime ( ) const
inline

return timer runtime converted ConvertUnit with ConvertPrecision e.g. for printing purposes.

Referenced by NES::TEST().

Here is the caller graph for this function:

◆ getRuntime()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
int64_t NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getRuntime ( ) const
inline

returns the current runtime

Note
will return zero if timer is not paused

References NES_DEBUG.

Referenced by NES::Compiler::CPPCompiler::compile(), NES::Compiler::CompilationResult::getCompilationTime(), and NES::TEST().

Here is the caller graph for this function:

◆ getRuntimeFromSnapshot()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
int64_t NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getRuntimeFromSnapshot ( const std::string &  snapShotName)
inline

Returns the runtime of the snapshot with the snapShotName.

Parameters
snapShotName
Returns
Runtime

References NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::snapshot().

Here is the call graph for this function:

◆ getSnapshots()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
const std::vector<Snapshot>& NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getSnapshots ( ) const
inline

returns the currently saved snapshots

Returns
reference to the saved snapshots

Referenced by NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::merge(), and NES::TEST().

Here is the caller graph for this function:

◆ getTimeUnitString()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
template<typename ConvertUnit = PrintTimeUnit>
static std::string NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getTimeUnitString ( )
inlinestatic

helper function to return a time unit literal string based on PrintTimeUnit

Referenced by NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::printHelper().

Here is the caller graph for this function:

◆ merge()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
void NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::merge ( Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >  timer)
inline

includes snapshots of another timer instance into this instance and adds overall runtime.

Parameters
timerto be merged with

References NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getComponentName(), NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getSnapshots(), and NES_DEBUG.

Referenced by NES::TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pause()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
void NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::pause ( )
inline

pauses the timer

References NES_DEBUG.

Referenced by NES::Compiler::CPPCompiler::compile(), and NES::TEST().

Here is the caller graph for this function:

◆ printHelper()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
static std::string NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::printHelper ( std::string  str,
Snapshot  s 
)
inlinestatic

helper function for insert string operator recursively goes through the (probably) nested snapshots and prints them

References NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::Snapshot::children, NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::Snapshot::getPrintTime(), NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getTimeUnitString(), and NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::Snapshot::name.

Here is the call graph for this function:

◆ snapshot()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
void NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::snapshot ( std::string  snapshotName)
inline

saves current runtime as a snapshot. Useful for measuring the time of sub-components.

Note
The runtime is the time from the last taken snapshot till now if saveSnapshot was called earlier. Otherwise it is the time from the start call till now.
Parameters
snapshotNamethe of the snapshot

References NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::createFullyQualifiedSnapShotName(), and NES_DEBUG.

Referenced by NES::QueryCompilation::SampleCPPCodeGenerator::compileQuery(), NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::getRuntimeFromSnapshot(), and NES::TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
void NES::Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType >::start ( )
inline

starts the timer or resumes it after a pause

References NES_DEBUG.

Referenced by NES::Compiler::CPPCompiler::compile(), NES::QueryCompilation::SampleCPPCodeGenerator::compileQuery(), and NES::TEST().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

template<typename TimeUnit = std::chrono::nanoseconds, typename PrintTimeUnit = std::milli, typename PrintTimePrecision = double, typename ClockType = std::chrono::high_resolution_clock>
std::ostream& operator<< ( std::ostream &  str,
const Timer< TimeUnit, PrintTimeUnit, PrintTimePrecision, ClockType > &  t 
)
friend

overwrites insert string operator


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