Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
dart::TimerImpl< Measure > Class Template Reference

#include <timer.h>

Inheritance diagram for dart::TimerImpl< Measure >:
dart::ValueObject

Public Member Functions

 TimerImpl ()
 
 ~TimerImpl ()
 
void Start ()
 
void Stop ()
 
int64_t TotalElapsedTime () const
 
int64_t MaxContiguous () const
 
void Reset ()
 
bool IsReset () const
 
void AddTotal (const TimerImpl &other)
 
bool running () const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Friends

class Timer
 

Detailed Description

template<typename Measure>
class dart::TimerImpl< Measure >

Definition at line 26 of file timer.h.

Constructor & Destructor Documentation

◆ TimerImpl()

template<typename Measure >
dart::TimerImpl< Measure >::TimerImpl ( )
inline

Definition at line 28 of file timer.h.

28{ Reset(); }
void Reset()
Definition timer.h:67

◆ ~TimerImpl()

template<typename Measure >
dart::TimerImpl< Measure >::~TimerImpl ( )
inline

Definition at line 29 of file timer.h.

29{}

Member Function Documentation

◆ AddTotal()

template<typename Measure >
void dart::TimerImpl< Measure >::AddTotal ( const TimerImpl< Measure > &  other)
inline

Definition at line 80 of file timer.h.

80{ total_.fetch_add(other.total_); }
T fetch_add(T arg, std::memory_order order=std::memory_order_relaxed)
Definition atomic.h:35

◆ IsReset()

template<typename Measure >
bool dart::TimerImpl< Measure >::IsReset ( ) const
inline

Definition at line 75 of file timer.h.

75 {
76 return (start_ == 0) && (stop_ == 0) && (total_ == 0) &&
77 (max_contiguous_ == 0) && !running_;
78 }

◆ MaxContiguous()

template<typename Measure >
int64_t dart::TimerImpl< Measure >::MaxContiguous ( ) const
inline

Definition at line 58 of file timer.h.

58 {
59 int64_t result = max_contiguous_;
60 if (running_) {
61 int64_t now = Measure::Now();
62 result = Utils::Maximum(result, now - start_);
63 }
64 return result;
65 }
static constexpr T Maximum(T x, T y)
Definition utils.h:26
GAsyncResult * result

◆ Reset()

template<typename Measure >
void dart::TimerImpl< Measure >::Reset ( )
inline

Definition at line 67 of file timer.h.

67 {
68 start_ = 0;
69 stop_ = 0;
70 total_ = 0;
71 max_contiguous_ = 0;
72 running_ = false;
73 }

◆ running()

template<typename Measure >
bool dart::TimerImpl< Measure >::running ( ) const
inline

Definition at line 83 of file timer.h.

83{ return running_; }

◆ Start()

template<typename Measure >
void dart::TimerImpl< Measure >::Start ( )
inline

Definition at line 32 of file timer.h.

32 {
33 start_ = Measure::Now();
34 running_ = true;
35 }

◆ Stop()

template<typename Measure >
void dart::TimerImpl< Measure >::Stop ( )
inline

Definition at line 38 of file timer.h.

38 {
39 ASSERT(running());
40 stop_ = Measure::Now();
41 int64_t elapsed = ElapsedMicros();
42 max_contiguous_ = Utils::Maximum(max_contiguous_.load(), elapsed);
43 // Make increment atomic in case it occurs in parallel with aggregation.
44 total_.fetch_add(elapsed);
45 running_ = false;
46 }
T load(std::memory_order order=std::memory_order_relaxed) const
Definition atomic.h:21
bool running() const
Definition timer.h:83
#define ASSERT(E)

◆ TotalElapsedTime()

template<typename Measure >
int64_t dart::TimerImpl< Measure >::TotalElapsedTime ( ) const
inline

Definition at line 49 of file timer.h.

49 {
50 int64_t result = total_;
51 if (running_) {
52 int64_t now = Measure::Now();
53 result += (now - start_);
54 }
55 return result;
56 }

Friends And Related Symbol Documentation

◆ Timer

template<typename Measure >
friend class Timer
friend

Definition at line 86 of file timer.h.


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