~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/ThirdParty/ANGLE/util/Timer.cpp

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}