Colobot
Loading...
Searching...
No Matches
timeutils.h File Reference

Some useful cross-platform operations on timestamps. More...

#include <chrono>
Include dependency graph for timeutils.h:

Typedefs

using TimeUtils::TimeStamp = std::chrono::time_point<std::chrono::high_resolution_clock>

Enumerations

enum class  TimeUnit { SECONDS , MILLISECONDS , MICROSECONDS }

Functions

TimeStamp TimeUtils::Lerp (TimeStamp a, TimeStamp b, float t)
 Linearly interpolates between two timestamps.
float TimeUtils::Diff (TimeStamp before, TimeStamp after, TimeUnit unit=TimeUnit::SECONDS)
 Returns a difference between two timestamps in given time unit.
long long TimeUtils::ExactDiff (TimeStamp before, TimeStamp after)
 Returns the exact (in nanosecond units) difference between two timestamps.

Detailed Description

Some useful cross-platform operations on timestamps.

Function Documentation

◆ Lerp()

TimeStamp TimeUtils::Lerp ( TimeStamp a,
TimeStamp b,
float t )

Linearly interpolates between two timestamps.

◆ Diff()

float TimeUtils::Diff ( TimeStamp before,
TimeStamp after,
TimeUnit unit = TimeUnit::SECONDS )

Returns a difference between two timestamps in given time unit.

The difference is after - before.

◆ ExactDiff()

long long TimeUtils::ExactDiff ( TimeStamp before,
TimeStamp after )

Returns the exact (in nanosecond units) difference between two timestamps.

The difference is after - before.