Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dart::Timer Class Reference

#include <timer.h>

Inheritance diagram for dart::Timer:
dart::ValueObject

Public Member Functions

 Timer (int64_t elapsed, int64_t elapsed_cpu)
 
 Timer ()
 
 ~Timer ()
 
void Start ()
 
void Stop ()
 
int64_t TotalElapsedTime () const
 
int64_t TotalElapsedTimeCpu () const
 
int64_t MaxContiguous () const
 
void Reset ()
 
bool IsReset () const
 
void AddTotal (const Timer &other)
 
const char * FormatElapsedHumanReadable (Zone *zone) const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Member Functions

static const char * FormatTime (Zone *zone, int64_t total)
 
static const char * FormatElapsedHumanReadable (Zone *zone, int64_t total_elapsed, int64_t total_elapsed_cpu)
 

Static Public Attributes

static constexpr double kCpuTimeReportingThreshold = 0.05
 

Detailed Description

Definition at line 103 of file timer.h.

Constructor & Destructor Documentation

◆ Timer() [1/2]

dart::Timer::Timer ( int64_t  elapsed,
int64_t  elapsed_cpu 
)
inline

Definition at line 105 of file timer.h.

106 : monotonic_(elapsed), cpu_(elapsed) {}

◆ Timer() [2/2]

dart::Timer::Timer ( )
inline

Definition at line 107 of file timer.h.

107{ Reset(); }
void Reset()
Definition: timer.h:128

◆ ~Timer()

dart::Timer::~Timer ( )
inline

Definition at line 108 of file timer.h.

108{}

Member Function Documentation

◆ AddTotal()

void dart::Timer::AddTotal ( const Timer other)
inline

Definition at line 135 of file timer.h.

135 {
136 monotonic_.AddTotal(other.monotonic_);
137 cpu_.AddTotal(other.cpu_);
138 }

◆ FormatElapsedHumanReadable() [1/2]

const char * dart::Timer::FormatElapsedHumanReadable ( Zone zone) const
inline

Definition at line 140 of file timer.h.

140 {
143 }
const char * FormatElapsedHumanReadable(Zone *zone) const
Definition: timer.h:140
int64_t TotalElapsedTimeCpu() const
Definition: timer.h:124
int64_t TotalElapsedTime() const
Definition: timer.h:123

◆ FormatElapsedHumanReadable() [2/2]

static const char * dart::Timer::FormatElapsedHumanReadable ( Zone zone,
int64_t  total_elapsed,
int64_t  total_elapsed_cpu 
)
inlinestatic

Definition at line 162 of file timer.h.

164 {
165 if ((total_elapsed == 0) ||
166 static_cast<double>(Utils::Abs(total_elapsed - total_elapsed_cpu) /
167 total_elapsed) < kCpuTimeReportingThreshold) {
168 return FormatTime(zone, total_elapsed);
169 } else {
170 return OS::SCreate(zone, "%s (cpu %s)", FormatTime(zone, total_elapsed),
171 FormatTime(zone, total_elapsed_cpu));
172 }
173 }
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
static const char * FormatTime(Zone *zone, int64_t total)
Definition: timer.h:145
static constexpr double kCpuTimeReportingThreshold
Definition: timer.h:155
static T Abs(T x)
Definition: utils.h:49

◆ FormatTime()

static const char * dart::Timer::FormatTime ( Zone zone,
int64_t  total 
)
inlinestatic

Definition at line 145 of file timer.h.

145 {
146 if (total > kMicrosecondsPerSecond) {
147 return OS::SCreate(zone, "%6.2f s", MicrosecondsToSeconds(total));
148 } else if (total > kMicrosecondsPerMillisecond) {
149 return OS::SCreate(zone, "%6.2f ms", MicrosecondsToMilliseconds(total));
150 } else {
151 return OS::SCreate(zone, "%6" Pd64 " \u00B5s", total);
152 }
153 }
constexpr intptr_t kMicrosecondsPerMillisecond
Definition: globals.h:561
constexpr double MicrosecondsToSeconds(int64_t micros)
Definition: globals.h:571
constexpr intptr_t kMicrosecondsPerSecond
Definition: globals.h:562
constexpr double MicrosecondsToMilliseconds(int64_t micros)
Definition: globals.h:574
#define Pd64
Definition: globals.h:416

◆ IsReset()

bool dart::Timer::IsReset ( ) const
inline

Definition at line 133 of file timer.h.

133{ return monotonic_.IsReset(); }

◆ MaxContiguous()

int64_t dart::Timer::MaxContiguous ( ) const
inline

Definition at line 126 of file timer.h.

126{ return monotonic_.MaxContiguous(); }

◆ Reset()

void dart::Timer::Reset ( )
inline

Definition at line 128 of file timer.h.

128 {
129 monotonic_.Reset();
130 cpu_.Reset();
131 }

◆ Start()

void dart::Timer::Start ( )
inline

Definition at line 111 of file timer.h.

111 {
112 cpu_.Start();
113 monotonic_.Start();
114 }

◆ Stop()

void dart::Timer::Stop ( )
inline

Definition at line 117 of file timer.h.

117 {
118 cpu_.Stop();
119 monotonic_.Stop();
120 }

◆ TotalElapsedTime()

int64_t dart::Timer::TotalElapsedTime ( ) const
inline

Definition at line 123 of file timer.h.

123{ return monotonic_.TotalElapsedTime(); }

◆ TotalElapsedTimeCpu()

int64_t dart::Timer::TotalElapsedTimeCpu ( ) const
inline

Definition at line 124 of file timer.h.

124{ return cpu_.TotalElapsedTime(); }

Member Data Documentation

◆ kCpuTimeReportingThreshold

constexpr double dart::Timer::kCpuTimeReportingThreshold = 0.05
staticconstexpr

Definition at line 155 of file timer.h.


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