SOFA API  4006d812
Open source framework for multi-physics simuation
sofa::helper::SimpleTimer< Unit > Class Template Reference

#include <SimpleTimer.h>

A RAII utility class for measuring elapsed time in operations and log it. More...

Detailed Description

template<class Unit = std::chrono::nanoseconds>
class sofa::helper::SimpleTimer< Unit >

A RAII utility class for measuring elapsed time in operations and log it.

// Measure a block of code
{
// ... Simulate file reading/writing here ...
// The elapsed time is logged by the timer at the end of the scope
}
A RAII utility class for measuring elapsed time in operations and log it.
Definition: SimpleTimer.h:69

Public Attributes

std::string m_name
 
std::chrono::time_point< std::chrono::high_resolution_clock > m_start
 
bool hasEnded { false }
 

Public Member Functions

 SimpleTimer (const std::string &name)
 
 ~SimpleTimer ()
 
void restart ()
 
void stop ()
 

Attribute details

◆ hasEnded

template<class Unit = std::chrono::nanoseconds>
bool sofa::helper::SimpleTimer< Unit >::hasEnded { false }

◆ m_name

template<class Unit = std::chrono::nanoseconds>
std::string sofa::helper::SimpleTimer< Unit >::m_name

◆ m_start

template<class Unit = std::chrono::nanoseconds>
std::chrono::time_point<std::chrono::high_resolution_clock> sofa::helper::SimpleTimer< Unit >::m_start

Constructor details

◆ SimpleTimer()

template<class Unit = std::chrono::nanoseconds>
sofa::helper::SimpleTimer< Unit >::SimpleTimer ( const std::string &  name)
inlineexplicit

◆ ~SimpleTimer()

template<class Unit = std::chrono::nanoseconds>
sofa::helper::SimpleTimer< Unit >::~SimpleTimer ( )
inline

Function details

◆ restart()

template<class Unit = std::chrono::nanoseconds>
void sofa::helper::SimpleTimer< Unit >::restart ( )
inline

◆ stop()

template<class Unit = std::chrono::nanoseconds>
void sofa::helper::SimpleTimer< Unit >::stop ( )
inline