|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Class Now is a practical class for timing based in a high resolution clock. More...
#include <ahNow.H>
Public Types | |
| enum class | Precision { Hours , Minutes , Seconds , Milliseconds , Microseconds , Nanoseconds } |
| Precision for timing. More... | |
| using | ClockType = std::chrono::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. | |
| Now (const Precision &_precision, bool start_now=false) | |
| Builds a new object with parametric precision time. | |
| const Precision & | get_precision () const |
| Gets the type of precision. | |
| void | set_precision (const Precision &_precision) |
| Sets the type of precision. | |
| TimePointType | start () |
| Sets internally the current time point. | |
| double | elapsed () |
| Calculates the time that has elapsed since the last time start(), elapsed() or delta() was called. | |
| double | delta () |
| Like elapsed(). | |
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) |
| Calculates the time that has elapsed between two time points. | |
| static double | elapsed (const TimePointType &tp, const Precision &precision=Precision::Milliseconds) |
| Calculates the time that has elapsed since a given time point. | |
| static double | delta (const TimePointType &tp, const Precision &precision=Precision::Milliseconds) |
| Like elapsed(const TimePointType & tp, const Precision & precision = MILLISECONDS). | |
Private Attributes | |
| TimePointType | tp |
| Precision | precision |
Static Private Attributes | |
| static const double | precision_values [] |
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:
| using Aleph::Now::ClockType = std::chrono::high_resolution_clock |
| using Aleph::Now::DurationType = ClockType::duration |
| using Aleph::Now::TimePointType = ClockType::time_point |
|
strong |
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. |
Definition at line 143 of file ahNow.H.
References Aleph::maps(), and start().
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. |
Definition at line 162 of file ahNow.H.
References Aleph::maps(), and start().
|
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. |
Definition at line 123 of file ahNow.H.
References Aleph::maps(), precision, precision_values, and to_int().
|
inlinestatic |
|
inline |
|
inlinestatic |
|
inline |
Calculates the time that has elapsed since the last time start(), elapsed() or delta() was called.
The value calculated depends of precision.
Definition at line 209 of file ahNow.H.
References compute_time_diff(), current_time_point(), Aleph::maps(), precision, and tp.
|
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. |
Definition at line 236 of file ahNow.H.
References compute_time_diff(), current_time_point(), precision, and tp.
Sets the type of precision.
Definition at line 182 of file ahNow.H.
References Aleph::maps(), and precision.
|
inline |
Sets internally the current time point.
This method must be used before calling elapsed() or delta() the first time.
Definition at line 195 of file ahNow.H.
References current_time_point(), and tp.
Definition at line 92 of file ahNow.H.
Referenced by compute_time_diff().
|
private |
Definition at line 104 of file ahNow.H.
Referenced by compute_time_diff(), delta(), elapsed(), elapsed(), get_precision(), and set_precision().
Definition at line 35 of file ahNow.H.
Referenced by compute_time_diff().
|
private |