KiCad PCB EDA Suite
SCOPED_PROF_COUNTER< DURATION > Class Template Reference

A simple RAII class to measure the time of an operation. More...

#include <profile.h>

Public Member Functions

 SCOPED_PROF_COUNTER (DURATION &aDuration)
 
 ~SCOPED_PROF_COUNTER ()
 

Private Attributes

PROF_COUNTER m_counter
 < The counter to use to do the profiling More...
 
DURATION & m_duration
 

Detailed Description

template<typename DURATION>
class SCOPED_PROF_COUNTER< DURATION >

A simple RAII class to measure the time of an operation.

On construction, a timer is started, and on destruction, the timer is ended, and the time difference is written into the given duration.

For example:

DURATION duration; // select a duration type as needed { SCOPED_PROF_COUNTER<DURATION> timer( duration ); timed_activity(); } // duration is now the time timed activity took

From C++17, with class template argument deduction, you should be able to omit the <DURATION>.

Definition at line 179 of file profile.h.

Constructor & Destructor Documentation

◆ SCOPED_PROF_COUNTER()

template<typename DURATION >
SCOPED_PROF_COUNTER< DURATION >::SCOPED_PROF_COUNTER ( DURATION &  aDuration)
inline

Definition at line 182 of file profile.h.

182  : m_counter(), m_duration( aDuration )
183  {
184  }
PROF_COUNTER m_counter
< The counter to use to do the profiling
Definition: profile.h:194
DURATION & m_duration
Definition: profile.h:197

◆ ~SCOPED_PROF_COUNTER()

template<typename DURATION >
SCOPED_PROF_COUNTER< DURATION >::~SCOPED_PROF_COUNTER ( )
inline

Definition at line 186 of file profile.h.

187  {
188  // update the output
189  m_duration = m_counter.SinceStart<DURATION>();
190  }
PROF_COUNTER m_counter
< The counter to use to do the profiling
Definition: profile.h:194
DURATION SinceStart(bool aSinceLast=false)
Definition: profile.h:129
DURATION & m_duration
Definition: profile.h:197

References SCOPED_PROF_COUNTER< DURATION >::m_counter, SCOPED_PROF_COUNTER< DURATION >::m_duration, and PROF_COUNTER::SinceStart().

Member Data Documentation

◆ m_counter

template<typename DURATION >
PROF_COUNTER SCOPED_PROF_COUNTER< DURATION >::m_counter
private

< The counter to use to do the profiling

The duration to update at the end of the scope

Definition at line 194 of file profile.h.

Referenced by SCOPED_PROF_COUNTER< DURATION >::~SCOPED_PROF_COUNTER().

◆ m_duration

template<typename DURATION >
DURATION& SCOPED_PROF_COUNTER< DURATION >::m_duration
private

Definition at line 197 of file profile.h.

Referenced by SCOPED_PROF_COUNTER< DURATION >::~SCOPED_PROF_COUNTER().


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