forked from HeliumProject/Platform
/
Timer.h
50 lines (42 loc) · 1013 Bytes
/
Timer.h
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
#pragma once
#include "Platform/System.h"
#include "Platform/Utility.h"
#include "Platform/Thread.h"
#if !HELIUM_OS_WIN
# include <signal.h>
# include <time.h>
#endif
namespace Helium
{
/// Application timer support.
class HELIUM_PLATFORM_API Timer
{
public:
/// @name Static Timing Support
//@{
static uint64_t GetTickCount();
static uint64_t GetTicksPerSecond();
static float64_t GetSecondsPerTick();
static float64_t TicksToMilliseconds( uint64_t ticks );
//@}
private:
/// Performance counter frequency.
static uint64_t sm_ticksPerSecond;
/// Seconds per performance counter tick.
static float64_t sm_secondsPerTick;
};
/// Simple timer object.
class HELIUM_PLATFORM_API SimpleTimer : NonCopyable
{
public:
/// Initialize the timer (start timing).
SimpleTimer();
/// Restart the timer.
void Reset();
/// Get elapsed time in milliseconds.
float64_t Elapsed();
private:
/// Tick count since the last time the timer was reset.
uint64_t m_StartTime;
};
}