DeSiGNAR
0.5a
Data Structures General Library
|
#include <now.H>
Public Types | |
enum | Precision { Precision::HOURS, Precision::MINUTES, Precision::SECONDS, Precision::MILLISECONDS, Precision::MICROSECONDS, Precision::NANOSECONDS } |
Precision for timing. More... | |
Public Member Functions | |
Now (bool start_now=false) | |
Builds a new object with default values. More... | |
Now (const Precision &_precision, bool start_now=false) | |
Builds a new object with parametric precision time. More... | |
const Precision & | get_precision () const |
void | set_precision (const Precision &_precision) |
time_point_t | start () |
double | elapsed () |
double | delta () |
Static Public Member Functions | |
static int | to_int (Precision p) |
static time_point_t | current_time_point () |
Gets the current time point. More... | |
static double | compute_time_diff (const time_point_t &rtp, const time_point_t <p, const Precision &precision) |
static double | elapsed (const time_point_t &tp, const Precision &precision=Precision::MILLISECONDS) |
static double | delta (const time_point_t &tp, const Precision &precision=Precision::MILLISECONDS) |
Class Now is a practical class for timing based in a high resolution clock.
An instance of this class allows to measure elapsed time between two instants.
Usage example:
Furthermore you may use the static methods just like that:
|
strong |
|
inline |
Builds a new object with default values.
Builds a new object with default time point and precision in MILLISECONDS. You may set the object to start counting time immediately by setting the parameter start_now in true. This constructor can be used as parametric or default.
start_now | If true, then the object starts counting the time immediately. By default is false. |
|
inline |
Builds a new object with parametric precision time.
Builds a new object with default time point and precision given as a parameter. You may set the object to start counting time immediately by setting the parameter start_now in true.
_precision | The type of precision for timing. |
start_now | If true, then the object starts counting the time immediately. By default is false. |
|
inlinestatic |
Calculates the time that has elapsed between two time points.
rtp | Right time point. |
ltp | Left time point. |
precision | Type of precision for calculating the time. |
|
inlinestatic |
Gets the current time point.
|
inlinestatic |
Like elapsed(const time_point_t & tp, const Precision & precision = MILLISECONDS).
|
inline |
|
inlinestatic |
Calculates the time that has elapsed since a given time point.
This is a class method. It's useful when is required massive time calculations and is not desired massive object instances of Now.
tp | Time point from which you want to calculate. |
precision | The type of precision for timing, by default is MILLISECONDS. |
|
inline |
Gets the type of precision.
|
inline |
Sets the type of precision.
|
inline |
Sets internally the current time point.
This method must be used before calling elapsed() or delta() the first time.
|
inlinestatic |