Flutter Engine
 
Loading...
Searching...
No Matches
fml::TimeDelta Class Reference

#include <time_delta.h>

Public Member Functions

constexpr TimeDelta ()=default
 
constexpr int64_t ToNanoseconds () const
 
constexpr int64_t ToMicroseconds () const
 
constexpr int64_t ToMilliseconds () const
 
constexpr int64_t ToSeconds () const
 
constexpr double ToNanosecondsF () const
 
constexpr double ToMicrosecondsF () const
 
constexpr double ToMillisecondsF () const
 
constexpr double ToSecondsF () const
 
constexpr TimeDelta operator- (TimeDelta other) const
 
constexpr TimeDelta operator+ (TimeDelta other) const
 
constexpr TimeDelta operator/ (int64_t divisor) const
 
constexpr int64_t operator/ (TimeDelta other) const
 
constexpr TimeDelta operator* (int64_t multiplier) const
 
constexpr TimeDelta operator% (TimeDelta other) const
 
constexpr auto operator<=> (const TimeDelta &other) const =default
 
struct timespec ToTimespec ()
 

Static Public Member Functions

static constexpr TimeDelta Zero ()
 
static constexpr TimeDelta Min ()
 
static constexpr TimeDelta Max ()
 
static constexpr TimeDelta FromNanoseconds (int64_t nanos)
 
static constexpr TimeDelta FromMicroseconds (int64_t micros)
 
static constexpr TimeDelta FromMilliseconds (int64_t millis)
 
static constexpr TimeDelta FromSeconds (int64_t seconds)
 
static constexpr TimeDelta FromSecondsF (double seconds)
 
static constexpr TimeDelta FromMillisecondsF (double millis)
 
static constexpr TimeDelta FromTimespec (struct timespec ts)
 

Detailed Description

Definition at line 29 of file time_delta.h.

Constructor & Destructor Documentation

◆ TimeDelta()

constexpr fml::TimeDelta::TimeDelta ( )
constexprdefault

Referenced by FromNanoseconds(), Max(), Min(), and Zero().

Member Function Documentation

◆ FromMicroseconds()

static constexpr TimeDelta fml::TimeDelta::FromMicroseconds ( int64_t  micros)
inlinestaticconstexpr

Definition at line 43 of file time_delta.h.

43 {
44 return FromNanoseconds(micros * 1000);
45 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition time_delta.h:40

References FromNanoseconds().

Referenced by FromMilliseconds(), flutter::RuntimeController::NotifyIdle(), flutter::testing::TEST(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ FromMilliseconds()

◆ FromMillisecondsF()

static constexpr TimeDelta fml::TimeDelta::FromMillisecondsF ( double  millis)
inlinestaticconstexpr

Definition at line 57 of file time_delta.h.

57 {
58 return FromNanoseconds(millis * (1000.0 * 1000.0));
59 }

References FromNanoseconds().

Referenced by flutter::TEST(), flutter::TEST(), flutter::TEST(), flutter::TEST(), and flutter::TEST().

◆ FromNanoseconds()

static constexpr TimeDelta fml::TimeDelta::FromNanoseconds ( int64_t  nanos)
inlinestaticconstexpr

◆ FromSeconds()

static constexpr TimeDelta fml::TimeDelta::FromSeconds ( int64_t  seconds)
inlinestaticconstexpr

◆ FromSecondsF()

static constexpr TimeDelta fml::TimeDelta::FromSecondsF ( double  seconds)
inlinestaticconstexpr

Definition at line 53 of file time_delta.h.

53 {
54 return FromNanoseconds(seconds * (1000.0 * 1000.0 * 1000.0));
55 }

References FromNanoseconds().

Referenced by flutter::testing::ShellTest::PumpOneFrame(), flutter::SamplingProfiler::Start(), flutter::TEST(), and TEST().

◆ FromTimespec()

static constexpr TimeDelta fml::TimeDelta::FromTimespec ( struct timespec  ts)
inlinestaticconstexpr

Definition at line 101 of file time_delta.h.

101 {
102 return TimeDelta::FromSeconds(ts.tv_sec) +
103 TimeDelta::FromNanoseconds(ts.tv_nsec);
104 }
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition time_delta.h:49

References FromNanoseconds(), and FromSeconds().

◆ Max()

static constexpr TimeDelta fml::TimeDelta::Max ( )
inlinestaticconstexpr

Definition at line 37 of file time_delta.h.

37 {
38 return TimeDelta(std::numeric_limits<int64_t>::max());
39 }

References TimeDelta().

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ Min()

static constexpr TimeDelta fml::TimeDelta::Min ( )
inlinestaticconstexpr

Definition at line 34 of file time_delta.h.

34 {
35 return TimeDelta(std::numeric_limits<int64_t>::min());
36 }

References TimeDelta().

◆ operator%()

constexpr TimeDelta fml::TimeDelta::operator% ( TimeDelta  other) const
inlineconstexpr

Definition at line 95 of file time_delta.h.

95 {
96 return TimeDelta::FromNanoseconds(delta_ % other.delta_);
97 }

References FromNanoseconds().

◆ operator*()

constexpr TimeDelta fml::TimeDelta::operator* ( int64_t  multiplier) const
inlineconstexpr

Definition at line 91 of file time_delta.h.

91 {
92 return TimeDelta::FromNanoseconds(delta_ * multiplier);
93 }

References FromNanoseconds().

◆ operator+()

constexpr TimeDelta fml::TimeDelta::operator+ ( TimeDelta  other) const
inlineconstexpr

Definition at line 79 of file time_delta.h.

79 {
80 return TimeDelta::FromNanoseconds(delta_ + other.delta_);
81 }

References FromNanoseconds().

◆ operator-()

constexpr TimeDelta fml::TimeDelta::operator- ( TimeDelta  other) const
inlineconstexpr

Definition at line 75 of file time_delta.h.

75 {
76 return TimeDelta::FromNanoseconds(delta_ - other.delta_);
77 }

References FromNanoseconds().

◆ operator/() [1/2]

constexpr TimeDelta fml::TimeDelta::operator/ ( int64_t  divisor) const
inlineconstexpr

Definition at line 83 of file time_delta.h.

83 {
84 return TimeDelta::FromNanoseconds(delta_ / divisor);
85 }

References FromNanoseconds().

◆ operator/() [2/2]

constexpr int64_t fml::TimeDelta::operator/ ( TimeDelta  other) const
inlineconstexpr

Definition at line 87 of file time_delta.h.

87 {
88 return delta_ / other.delta_;
89 }

◆ operator<=>()

constexpr auto fml::TimeDelta::operator<=> ( const TimeDelta other) const
constexprdefault

◆ ToMicroseconds()

constexpr int64_t fml::TimeDelta::ToMicroseconds ( ) const
inlineconstexpr

◆ ToMicrosecondsF()

constexpr double fml::TimeDelta::ToMicrosecondsF ( ) const
inlineconstexpr

Definition at line 67 of file time_delta.h.

67{ return delta_ / 1000.0; }

◆ ToMilliseconds()

constexpr int64_t fml::TimeDelta::ToMilliseconds ( ) const
inlineconstexpr

Definition at line 63 of file time_delta.h.

63{ return ToMicroseconds() / 1000; }
constexpr int64_t ToMicroseconds() const
Definition time_delta.h:62

References ToMicroseconds().

Referenced by ToSeconds().

◆ ToMillisecondsF()

constexpr double fml::TimeDelta::ToMillisecondsF ( ) const
inlineconstexpr

Definition at line 68 of file time_delta.h.

68 {
69 return delta_ / (1000.0 * 1000.0);
70 }

Referenced by flutter::PerformanceOverlayLayer::MakeStatisticsText(), and flutter::DlStopwatchVisualizer::Visualize().

◆ ToNanoseconds()

◆ ToNanosecondsF()

constexpr double fml::TimeDelta::ToNanosecondsF ( ) const
inlineconstexpr

Definition at line 66 of file time_delta.h.

66{ return delta_; }

◆ ToSeconds()

constexpr int64_t fml::TimeDelta::ToSeconds ( ) const
inlineconstexpr

Definition at line 64 of file time_delta.h.

64{ return ToMilliseconds() / 1000; }
constexpr int64_t ToMilliseconds() const
Definition time_delta.h:63

References ToMilliseconds().

Referenced by flutter::testing::PendingTests::CheckTimedOutTests(), and flutter::testing::TestTimeoutListener::TestTimeoutListener().

◆ ToSecondsF()

constexpr double fml::TimeDelta::ToSecondsF ( ) const
inlineconstexpr

Definition at line 71 of file time_delta.h.

71 {
72 return delta_ / (1000.0 * 1000.0 * 1000.0);
73 }

Referenced by impeller::testing::TEST_P().

◆ ToTimespec()

struct timespec fml::TimeDelta::ToTimespec ( )
inline

Definition at line 105 of file time_delta.h.

105 {
106 struct timespec ts;
107 constexpr int64_t kNanosecondsPerSecond = 1000000000ll;
108 ts.tv_sec = static_cast<time_t>(ToSeconds());
109 ts.tv_nsec = delta_ % kNanosecondsPerSecond;
110 return ts;
111 }
constexpr int64_t ToSeconds() const
Definition time_delta.h:64

◆ Zero()

static constexpr TimeDelta fml::TimeDelta::Zero ( )
inlinestaticconstexpr

The documentation for this class was generated from the following file: