[go: up one dir, main page]

blob: af5cefe48860c52f05f7e162f01487a4c6fb8127 [file] [log] [blame]
Geoff Lang49be2ad2014-02-28 18:05:511//
Shahbaz Youssefif0dd0872019-08-23 19:45:342// Copyright 2019 The ANGLE Project Authors. All rights reserved.
Geoff Lang49be2ad2014-02-28 18:05:513// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#ifndef SAMPLE_UTIL_TIMER_H
8#define SAMPLE_UTIL_TIMER_H
9
Jamie Madill9190f492019-12-16 21:03:5710class Timer final
Geoff Lang49be2ad2014-02-28 18:05:5111{
12 public:
Shahbaz Youssefif0dd0872019-08-23 19:45:3413 Timer();
14 ~Timer() {}
Shahbaz Youssefi479918d2018-10-22 15:53:5115
Lingfeng Yange9f9fa12021-11-10 02:13:1516 // Use start() and stop() to record the duration and use getElapsedWallClockTime() to query that
17 // duration. If getElapsedWallClockTime() is called in between, it will report the elapsed time
18 // since start().
Shahbaz Youssefif0dd0872019-08-23 19:45:3419 void start();
20 void stop();
Lingfeng Yange9f9fa12021-11-10 02:13:1521 double getElapsedWallClockTime() const;
22 double getElapsedCpuTime() const;
Shahbaz Youssefi479918d2018-10-22 15:53:5123
Shahbaz Youssefif0dd0872019-08-23 19:45:3424 private:
25 bool mRunning;
26 double mStartTime;
27 double mStopTime;
Lingfeng Yange9f9fa12021-11-10 02:13:1528 double mStartCpuTime;
29 double mStopCpuTime;
Geoff Lang49be2ad2014-02-28 18:05:5130};
31
Jamie Madillba319ba2018-12-29 15:29:3332#endif // SAMPLE_UTIL_TIMER_H