Reputation: 3757
I am trying to convert a C++ code into Python. What is the python equivalent that I can use to substitute std::chrono::steady_clock::now();
that gives an accurate timing of the current time on linux that I can compare to other time points.
void takeImages(steady_clock::time_point next_frame)
{
steady_clock::time_point current_time = steady_clock::now();
if (current_time >= next_frame) {
// do something if time right now is at or after next_frame
}
Upvotes: 2
Views: 2752
Reputation: 213378
This is equivalent to time.monotonic()
in Python. See time — Time access and conversions:
Return the value (in fractional seconds) of a monotonic clock, i.e. a clock that cannot go backwards. The clock is not affected by system clock updates. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid.
Unfortunately C++ uses unusual nomenclature here. "Monotonic" is the term that other standards and languages use for this kind of clock (C11, Posix, Python, etc).
Upvotes: 4