AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxUtil::TimerBlock Class Reference

Utility class to time a scope. More...

#include <TimerBlock.h>

Public Types

using OnDeleteCallback = std::function< void(agx::UInt64, agx::UInt64)>
 

Public Member Functions

 TimerBlock (OnDeleteCallback onDeleteCallback)
 Construct given title. More...
 
 ~TimerBlock ()
 Print during destruction. More...
 
void stop ()
 Stop the timer before we leave the scope. More...
 

Static Public Member Functions

template<typename... ArgsT>
static TimerBlock create (const agx::String &format, ArgsT &&...args)
 Create timer block given format string. More...
 

Detailed Description

Utility class to time a scope.

The title and time will be printed while this object is being destructed.

Definition at line 28 of file TimerBlock.h.

Member Typedef Documentation

Definition at line 31 of file TimerBlock.h.

Constructor & Destructor Documentation

agxUtil::TimerBlock::TimerBlock ( OnDeleteCallback  onDeleteCallback)
inline

Construct given title.

Print will be: {Timer Block}: $title

  • Execute time: $time ms.

Definition at line 68 of file TimerBlock.h.

Referenced by create().

agxUtil::TimerBlock::~TimerBlock ( )
inline

Print during destruction.

Definition at line 78 of file TimerBlock.h.

References agx::InvalidIndex, and stop().

Member Function Documentation

template<typename... ArgsT>
static TimerBlock agxUtil::TimerBlock::create ( const agx::String &  format,
ArgsT &&...  args 
)
inlinestatic

Create timer block given format string.

Example: for ( ... ) { auto tb = agxUtil::TimerBlock::create( "Iteration %d", i + 1 ); }

Will print: {Timer Block}: Iteration 1

  • Execute time: 0.000149955 ms. {Timer Block}: Iteration 2
  • Execute time: 0.002132455 ms. {Timer Block}: Iteration 3
  • Execute time: 0.000093941 ms. etc.

Definition at line 52 of file TimerBlock.h.

References agx::Timer::convertToMs(), agx::AgXString< std::string >::format(), stop(), and TimerBlock().

void agxUtil::TimerBlock::stop ( )
inline

Stop the timer before we leave the scope.

Definition at line 90 of file TimerBlock.h.

References agx::Timer::getCurrentTick().

Referenced by create(), and ~TimerBlock().


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