KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PROF_TIMER Class Reference

A small class to help profiling. More...

#include <profile.h>

Inheritance diagram for PROF_TIMER:
SCOPED_PROF_TIMER< DURATION >

Public Member Functions

 PROF_TIMER (const std::string &aName, bool aAutostart=true)
 Create a PROF_COUNTER for measuring an elapsed time in milliseconds.
 
 PROF_TIMER ()
 Create a PROF_COUNTER for measuring an elapsed time in milliseconds.
 
void Start ()
 Start or restart the counter.
 
void Stop ()
 Save the time when this function was called, and set the counter stane to stop.
 
void Show (std::ostream &aStream=std::cerr)
 Print the elapsed time (in a suitable unit) to a stream.
 
template<typename DURATION >
DURATION SinceStart (bool aSinceLast=false)
 
double msecs (bool aSinceLast=false)
 
std::string to_string ()
 

Private Types

using CLOCK = std::chrono::high_resolution_clock
 
using TIME_POINT = std::chrono::time_point< CLOCK >
 

Private Attributes

std::string m_name
 
bool m_running
 
TIME_POINT m_starttime
 
TIME_POINT m_lasttime
 
TIME_POINT m_stoptime
 

Detailed Description

A small class to help profiling.

It allows the calculation of the elapsed time (in milliseconds) between its creation (or the last call to Start() ) and the last call to Stop()

Definition at line 48 of file profile.h.

Member Typedef Documentation

◆ CLOCK

using PROF_TIMER::CLOCK = std::chrono::high_resolution_clock
private

Definition at line 186 of file profile.h.

◆ TIME_POINT

using PROF_TIMER::TIME_POINT = std::chrono::time_point<CLOCK>
private

Definition at line 187 of file profile.h.

Constructor & Destructor Documentation

◆ PROF_TIMER() [1/2]

PROF_TIMER::PROF_TIMER ( const std::string &  aName,
bool  aAutostart = true 
)
inline

Create a PROF_COUNTER for measuring an elapsed time in milliseconds.

Parameters
aNamea string that will be printed in message.
aAutostarttrue (default) to immediately start the timer

Definition at line 57 of file profile.h.

References Start().

◆ PROF_TIMER() [2/2]

PROF_TIMER::PROF_TIMER ( )
inline

Create a PROF_COUNTER for measuring an elapsed time in milliseconds.

The counter is started and the string to print in message is left empty.

Definition at line 69 of file profile.h.

References Start().

Member Function Documentation

◆ msecs()

◆ Show()

void PROF_TIMER::Show ( std::ostream &  aStream = std::cerr)
inline

Print the elapsed time (in a suitable unit) to a stream.

The unit is automatically chosen from ns, us, ms and s, depending on the size of the current count.

Parameters
thestream to print to.

Definition at line 105 of file profile.h.

References m_name.

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), RES_EQUIV_CALC::Calculate(), RN_NET::compute(), SCH_EDIT_FRAME::OpenProjectFiles(), CN_CONNECTIVITY_ALGO::searchConnections(), PCB_TEST_FRAME_BASE::SetBoard(), SCH_SCREEN::TestDanglingEnds(), and CONNECTIVITY_DATA::updateRatsnest().

◆ SinceStart()

template<typename DURATION >
DURATION PROF_TIMER::SinceStart ( bool  aSinceLast = false)
inline
Returns
the time since the timer was started. If the timer is stopped, the duration is from the start time to the time it was stopped, else it is to the current time.

Definition at line 135 of file profile.h.

References m_lasttime, m_running, m_starttime, and m_stoptime.

Referenced by parse(), and SCOPED_PROF_TIMER< DURATION >::~SCOPED_PROF_TIMER().

◆ Start()

void PROF_TIMER::Start ( )
inline

Start or restart the counter.

Definition at line 77 of file profile.h.

References m_lasttime, m_running, and m_starttime.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint(), KIGFX::OPENGL_GAL::EndDrawing(), PROF_TIMER(), and PCB_SELECTION_TOOL::selectAllConnectedTracks().

◆ Stop()

◆ to_string()

Member Data Documentation

◆ m_lasttime

TIME_POINT PROF_TIMER::m_lasttime
private

Definition at line 189 of file profile.h.

Referenced by SinceStart(), and Start().

◆ m_name

std::string PROF_TIMER::m_name
private

Definition at line 183 of file profile.h.

Referenced by Show(), and to_string().

◆ m_running

bool PROF_TIMER::m_running
private

Definition at line 184 of file profile.h.

Referenced by SinceStart(), Start(), and Stop().

◆ m_starttime

TIME_POINT PROF_TIMER::m_starttime
private

Definition at line 189 of file profile.h.

Referenced by SinceStart(), and Start().

◆ m_stoptime

TIME_POINT PROF_TIMER::m_stoptime
private

Definition at line 189 of file profile.h.

Referenced by SinceStart(), and Stop().


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