AGX Dynamics 2.41.1.2
Loading...
Searching...
No Matches
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.
 
 ~TimerBlock ()
 Print during destruction.
 
void stop ()
 Stop the timer before we leave the scope.
 

Static Public Member Functions

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

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

◆ OnDeleteCallback

Definition at line 31 of file TimerBlock.h.

Constructor & Destructor Documentation

◆ TimerBlock()

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.

◆ ~TimerBlock()

agxUtil::TimerBlock::~TimerBlock ( )
inline

Print during destruction.

Definition at line 78 of file TimerBlock.h.

References agx::InvalidIndex, and stop().

Member Function Documentation

◆ create()

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(), and stop().

◆ stop()

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 ~TimerBlock(), and create().


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