1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "Prerequisites/BsPrerequisitesUtil.h"
6
7namespace bs
8{
9 /** @addtogroup General
10 * @{
11 */
12
13 /** Timer class used for querying high precision timers. */
14 class BS_UTILITY_EXPORT Timer
15 {
16 public:
17 /** Construct the timer and start timing. */
18 Timer();
19
20 /** Reset the timer to zero. */
21 void reset();
22
23 /** Returns time in milliseconds since timer was initialized or last reset. */
24 UINT64 getMilliseconds() const;
25
26 /** Returns time in microseconds since timer was initialized or last reset. */
27 UINT64 getMicroseconds() const;
28
29 /**
30 * Returns the time at which the timer was initialized, in milliseconds.
31 *
32 * @return Time in milliseconds.
33 */
34 UINT64 getStartMs() const;
35
36 private:
37 std::chrono::high_resolution_clock mHRClock;
38 std::chrono::time_point<std::chrono::high_resolution_clock> mStartTime;
39 };
40
41 /** @} */
42}
43