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