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