2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2010-01-21 19:55:01 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
namespace Common
|
|
|
|
{
|
|
|
|
class Timer
|
|
|
|
{
|
2009-02-22 12:43:25 +00:00
|
|
|
public:
|
2022-07-18 03:43:47 +00:00
|
|
|
static u64 NowUs();
|
|
|
|
static u64 NowMs();
|
2009-02-22 12:43:25 +00:00
|
|
|
|
|
|
|
void Start();
|
2022-07-18 03:43:47 +00:00
|
|
|
// Start(), then decrement start time by the offset.
|
|
|
|
// Effectively "resumes" a timer
|
|
|
|
void StartWithOffset(u64 offset);
|
2009-02-22 12:43:25 +00:00
|
|
|
void Stop();
|
2022-07-18 03:43:47 +00:00
|
|
|
u64 ElapsedMs() const;
|
2009-02-22 12:43:25 +00:00
|
|
|
|
2022-07-18 07:20:26 +00:00
|
|
|
// The rest of these functions probably belong somewhere else
|
2022-07-18 03:43:47 +00:00
|
|
|
static u64 GetLocalTimeSinceJan1970();
|
2009-02-22 12:43:25 +00:00
|
|
|
|
|
|
|
static void IncreaseResolution();
|
|
|
|
static void RestoreResolution();
|
2010-01-21 19:55:01 +00:00
|
|
|
|
|
|
|
private:
|
2022-07-18 03:43:47 +00:00
|
|
|
u64 m_start_ms{0};
|
|
|
|
u64 m_end_ms{0};
|
|
|
|
bool m_running{false};
|
2008-07-12 17:40:22 +00:00
|
|
|
};
|
2009-02-22 12:43:25 +00:00
|
|
|
|
2009-03-28 08:57:34 +00:00
|
|
|
} // Namespace Common
|