• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // Timer.cpp: Implementation of a high precision timer class.
7 //
8 
9 #include "util/Timer.h"
10 
11 #include "common/system_utils.h"
12 
Timer()13 Timer::Timer() : mRunning(false), mStartTime(0), mStopTime(0) {}
14 
start()15 void Timer::start()
16 {
17     mStartTime = angle::GetCurrentTime();
18     mRunning   = true;
19 }
20 
stop()21 void Timer::stop()
22 {
23     mStopTime = angle::GetCurrentTime();
24     mRunning  = false;
25 }
26 
getElapsedTime() const27 double Timer::getElapsedTime() const
28 {
29     double endTime;
30     if (mRunning)
31     {
32         endTime = angle::GetCurrentTime();
33     }
34     else
35     {
36         endTime = mStopTime;
37     }
38 
39     return endTime - mStartTime;
40 }
41