blob: d49a599015571fc97d4a1eb201146e106a0ecee6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "Common/CommonTypes.h"
namespace Common
{
class Timer
{
public:
static u64 NowUs();
static u64 NowMs();
void Start();
// Start(), then decrement start time by the offset.
// Effectively "resumes" a timer
void StartWithOffset(u64 offset);
void Stop();
u64 ElapsedMs() const;
// The rest of these functions probably belong somewhere else
static u64 GetLocalTimeSinceJan1970();
static void IncreaseResolution();
static void RestoreResolution();
private:
u64 m_start_ms{0};
u64 m_end_ms{0};
bool m_running{false};
};
class PrecisionTimer
{
public:
PrecisionTimer();
~PrecisionTimer();
PrecisionTimer(const PrecisionTimer&) = delete;
PrecisionTimer& operator=(const PrecisionTimer&) = delete;
void SleepUntil(Clock::time_point);
private:
#ifdef _WIN32
// Using void* to avoid including Windows.h in this header just for HANDLE.
void* m_timer_handle;
#endif
};
} // Namespace Common
|