nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
system
HighResolutionTimer.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
******************************************************************************/
29
#ifndef NOMLIB_SYSTEM_HIGH_RESOLUTION_TIMER_HPP
30
#define NOMLIB_SYSTEM_HIGH_RESOLUTION_TIMER_HPP
31
32
#include "export.hpp"
33
#include "nomlib/config.hpp"
34
35
namespace
nom {
36
38
class
NOM_EXPORT
HighResolutionTimer
39
{
40
public
:
42
HighResolutionTimer
();
43
45
~HighResolutionTimer
();
46
47
bool
started()
const
;
48
bool
paused()
const
;
49
50
uint64 ticks()
const
;
51
52
std::string ticks_str()
const
;
53
54
void
start();
55
void
stop();
56
58
void
restart
();
59
60
void
pause();
61
void
unpause();
62
65
static
66
real64
elapsed_ticks
(uint64 start_hires_ticks, uint64 end_hires_ticks);
67
73
static
real64
to_milliseconds
(uint64 hires_ticks);
74
80
real64
to_seconds
()
const
;
81
87
static
real64
to_seconds
(uint64 hires_ticks);
88
89
private
:
91
bool
paused_
;
92
94
bool
started_
;
95
97
uint64
elapsed_ticks_
;
98
100
uint64
paused_ticks_
;
101
};
102
103
}
// namespace nom
104
105
#endif
// include guard defined
nom::HighResolutionTimer::paused_
bool paused_
Activity status of the timer.
Definition
HighResolutionTimer.hpp:91
nom::HighResolutionTimer::to_seconds
static real64 to_seconds(uint64 hires_ticks)
Convert a high resolution timing value to seconds.
nom::HighResolutionTimer::HighResolutionTimer
HighResolutionTimer()
Default constructor.
nom::HighResolutionTimer::restart
void restart()
Alias for start.
nom::HighResolutionTimer::started_
bool started_
Running status of the timer.
Definition
HighResolutionTimer.hpp:94
nom::HighResolutionTimer::elapsed_ticks
static real64 elapsed_ticks(uint64 start_hires_ticks, uint64 end_hires_ticks)
Get the elapsed frequency count per second of the high resolution counter.
nom::HighResolutionTimer::~HighResolutionTimer
~HighResolutionTimer()
Destructor.
nom::HighResolutionTimer::to_milliseconds
static real64 to_milliseconds(uint64 hires_ticks)
Convert a high resolution timing value to milliseconds.
nom::HighResolutionTimer::to_seconds
real64 to_seconds() const
Convert a high resolution timing value to seconds.
nom::HighResolutionTimer::paused_ticks_
uint64 paused_ticks_
The recorded timestamp at the time of pausing the timer.
Definition
HighResolutionTimer.hpp:100
nom::HighResolutionTimer::elapsed_ticks_
uint64 elapsed_ticks_
The recorded timestamp at the time of starting the timer.
Definition
HighResolutionTimer.hpp:97
Generated on
for nomlib by
1.18.0