5#ifndef FLUTTER_FML_TIME_TIME_DELTA_H_
6#define FLUTTER_FML_TIME_TIME_DELTA_H_
16using namespace std::chrono_literals;
35 return TimeDelta(std::numeric_limits<int64_t>::min());
38 return TimeDelta(std::numeric_limits<int64_t>::max());
69 return delta_ / (1000.0 * 1000.0);
72 return delta_ / (1000.0 * 1000.0 * 1000.0);
88 return delta_ / other.delta_;
112 constexpr int64_t kNanosecondsPerSecond = 1000000000ll;
113 ts.tv_sec =
static_cast<time_t
>(ToSeconds());
114 ts.tv_nsec = delta_ % kNanosecondsPerSecond;
120 explicit constexpr TimeDelta(int64_t delta) : delta_(delta) {}
struct timespec ToTimespec()
bool operator<(TimeDelta other) const
static constexpr TimeDelta FromSeconds(int64_t seconds)
constexpr TimeDelta operator%(TimeDelta other) const
constexpr double ToNanosecondsF() const
constexpr double ToMicrosecondsF() const
static constexpr TimeDelta FromTimespec(struct timespec ts)
constexpr int64_t ToMicroseconds() const
bool operator!=(TimeDelta other) const
bool operator<=(TimeDelta other) const
static constexpr TimeDelta FromMillisecondsF(double millis)
constexpr TimeDelta operator+(TimeDelta other) const
bool operator>=(TimeDelta other) const
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
constexpr TimeDelta operator/(int64_t divisor) const
constexpr TimeDelta operator*(int64_t multiplier) const
static constexpr TimeDelta FromSecondsF(double seconds)
constexpr double ToSecondsF() const
constexpr int64_t ToMilliseconds() const
constexpr double ToMillisecondsF() const
constexpr TimeDelta()=default
static constexpr TimeDelta FromMilliseconds(int64_t millis)
constexpr int64_t ToNanoseconds() const
constexpr int64_t operator/(TimeDelta other) const
bool operator>(TimeDelta other) const
static constexpr TimeDelta Min()
constexpr TimeDelta operator-(TimeDelta other) const
static constexpr TimeDelta Max()
constexpr int64_t ToSeconds() const
bool operator==(TimeDelta other) const
static constexpr TimeDelta FromMicroseconds(int64_t micros)
static constexpr TimeDelta Zero()
std::chrono::duration< double, std::milli > Milliseconds
constexpr Milliseconds kDefaultFrameBudget
Milliseconds RefreshRateToFrameBudget(T refresh_rate)