MarlinMT  0.1.0
marlinmt::clock Class Reference

clock class Provide a wrapper around a certain clock type in std to perform safe clock measurement in multi-threading environement More...

#include <Utils.h>

Public Types

using clock_type = std::chrono::steady_clock
 
using time_point = clock_type::time_point
 
using duration_rep = float
 
using pair = std::pair< duration_rep, duration_rep >
 
using nanoseconds = std::chrono::duration< duration_rep, std::nano >
 
using microseconds = std::chrono::duration< duration_rep, std::micro >
 
using milliseconds = std::chrono::duration< duration_rep, std::milli >
 
using seconds = std::chrono::duration< duration_rep >
 
using minutes = std::chrono::duration< duration_rep, std::ratio< 60 > >
 

Public Member Functions

 clock ()=delete
 
 ~clock ()=delete
 

Static Public Member Functions

static time_point now ()
 Get the current time. More...
 
template<class unit = seconds>
static duration_rep elapsed_since (const time_point &since)
 Get the elapsed time since a previous time point. More...
 
template<class unit = seconds>
static duration_rep time_difference (const time_point &older, const time_point &ealier)
 Get the time difference between two time points. More...
 
template<class unit = seconds>
static void crunchFor (duration_rep crunchTime)
 Crunch numbers for some time. More...
 

Detailed Description

clock class Provide a wrapper around a certain clock type in std to perform safe clock measurement in multi-threading environement

Definition at line 28 of file Utils.h.

Member Typedef Documentation

◆ clock_type

using marlinmt::clock::clock_type = std::chrono::steady_clock

Definition at line 30 of file Utils.h.

◆ duration_rep

Definition at line 32 of file Utils.h.

◆ microseconds

using marlinmt::clock::microseconds = std::chrono::duration<duration_rep, std::micro>

Definition at line 36 of file Utils.h.

◆ milliseconds

using marlinmt::clock::milliseconds = std::chrono::duration<duration_rep, std::milli>

Definition at line 37 of file Utils.h.

◆ minutes

using marlinmt::clock::minutes = std::chrono::duration<duration_rep, std::ratio<60> >

Definition at line 39 of file Utils.h.

◆ nanoseconds

using marlinmt::clock::nanoseconds = std::chrono::duration<duration_rep, std::nano>

Definition at line 35 of file Utils.h.

◆ pair

Definition at line 33 of file Utils.h.

◆ seconds

using marlinmt::clock::seconds = std::chrono::duration<duration_rep>

Definition at line 38 of file Utils.h.

◆ time_point

using marlinmt::clock::time_point = clock_type::time_point

Definition at line 31 of file Utils.h.

Constructor & Destructor Documentation

◆ clock()

marlinmt::clock::clock ( )
delete

◆ ~clock()

marlinmt::clock::~clock ( )
delete

Member Function Documentation

◆ crunchFor()

template<class unit = seconds>
static void marlinmt::clock::crunchFor ( duration_rep  crunchTime)
inlinestatic

Crunch numbers for some time.

The template parameter specifies the unit

Parameters
crunchTimethe time duration

Definition at line 99 of file Utils.h.

References now().

◆ elapsed_since()

template<class unit = seconds>
static duration_rep marlinmt::clock::elapsed_since ( const time_point since)
inlinestatic

Get the elapsed time since a previous time point.

The template parameter 'unit' allows for casting the result to a specific unit (default seconds). Use the duration types defined in this class to get a correct calculation. The result is floating type.

Parameters
sincean earlier time point

Definition at line 64 of file Utils.h.

References now().

◆ now()

◆ time_difference()

template<class unit = seconds>
static duration_rep marlinmt::clock::time_difference ( const time_point older,
const time_point ealier 
)
inlinestatic

Get the time difference between two time points.

The template parameter 'unit' allows for casting the result to a specific unit (default seconds). Use the duration types defined in this class to get a correct calculation. The result is floating type. Example:

auto start = clock::now();
// do stuff
auto end = clock::now();
// get the time difference in milliseconds as a float
auto ms_spent = clock::time_difference<clock::milliseconds>( start, end );
Parameters
olderthe oldest time point
ealierthe earliest time point

Definition at line 88 of file Utils.h.

Referenced by marlinmt::concurrency::PEPScheduler::end().


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