Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/util/Timer.cpp
1693 views
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
13
Timer::Timer() : mRunning(false), mStartTime(0), mStopTime(0) {}
14
15
void Timer::start()
16
{
17
mStartTime = angle::GetCurrentTime();
18
mRunning = true;
19
}
20
21
void Timer::stop()
22
{
23
mStopTime = angle::GetCurrentTime();
24
mRunning = false;
25
}
26
27
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
42