#include <ahNow.H>
Public Types | |
| enum | Precision { Hours, Minutes, Seconds, Milliseconds, Microseconds, Nanoseconds } |
| Precision for timing. | |
| using | ClockType = high_resolution_clock |
| using | TimePointType = ClockType::time_point |
| using | DurationType = ClockType::duration |
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) |
| TimePointType | start () |
| double | elapsed () |
| double | delta () |
Static Public Member Functions | |
| static int | to_int (Precision p) |
| static TimePointType | current_time_point () |
| Gets the current time point. | |
| static double | compute_time_diff (const TimePointType &rtp, const TimePointType <p, const Precision &precision) |
| static double | elapsed (const TimePointType &tp, const Precision &precision=Precision::Milliseconds) |
| static double | delta (const TimePointType &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:
|
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 |
|
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.