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