tesseract  5.0.0-alpha-619-ge9db
CycleTimer Class Reference

#include <cycletimer.h>

Public Member Functions

 CycleTimer ()
 
void Reset ()
 
void Start ()
 
void Restart ()
 
void Stop ()
 
int64_t GetInMs () const
 

Protected Member Functions

int64_t GetNanos () const
 

Detailed Description

Definition at line 19 of file cycletimer.h.

Constructor & Destructor Documentation

◆ CycleTimer()

CycleTimer::CycleTimer ( )
inline

Definition at line 21 of file cycletimer.h.

21  {
22  Reset();
23  }

Member Function Documentation

◆ GetInMs()

int64_t CycleTimer::GetInMs ( ) const
inline

Definition at line 48 of file cycletimer.h.

48 { return GetNanos() / 1000000; }

◆ GetNanos()

int64_t CycleTimer::GetNanos ( ) const
inlineprotected

Definition at line 51 of file cycletimer.h.

51  {
52  return running_ ? absl::GetCurrentTimeNanos() - start_ + sum_ : sum_;
53  }

◆ Reset()

void CycleTimer::Reset ( )
inline

Definition at line 25 of file cycletimer.h.

25  {
26  running_ = false;
27  sum_ = 0;
28  start_ = 0;
29  }

◆ Restart()

void CycleTimer::Restart ( )
inline

Definition at line 37 of file cycletimer.h.

37  {
38  sum_ = 0;
39  Start();
40  }

◆ Start()

void CycleTimer::Start ( )
inline

Definition at line 32 of file cycletimer.h.

32  {
33  running_ = true;
34  start_ = absl::GetCurrentTimeNanos();
35  }

◆ Stop()

void CycleTimer::Stop ( )
inline

Definition at line 42 of file cycletimer.h.

42  {
43  if (running_) {
44  sum_ += absl::GetCurrentTimeNanos() - start_;
45  running_ = false;
46  }
47  }

The documentation for this class was generated from the following file:
CycleTimer::Start
void Start()
Definition: cycletimer.h:32
CycleTimer::GetNanos
int64_t GetNanos() const
Definition: cycletimer.h:51
CycleTimer::Reset
void Reset()
Definition: cycletimer.h:25