MyGUI
3.4.2
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
MyGUIEngine
src
MyGUI_Timer.cpp
Go to the documentation of this file.
1
/*
2
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
3
* Distributed under the MIT License
4
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5
*/
6
7
#include "
MyGUI_Precompiled.h
"
8
#include "
MyGUI_Timer.h
"
9
10
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
11
# include <windows.h>
12
# pragma comment(lib, "winmm.lib")
13
#else
14
# include <sys/time.h>
15
#endif
16
17
namespace
MyGUI
18
{
19
20
Timer::Timer
() :
21
mTimeStart(0)
22
{
23
}
24
25
void
Timer::reset
()
26
{
27
mTimeStart = getCurrentMilliseconds();
28
}
29
30
unsigned
long
Timer::getMilliseconds
()
const
31
{
32
return
getCurrentMilliseconds() - mTimeStart;
33
}
34
35
unsigned
long
Timer::getCurrentMilliseconds()
const
36
{
37
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
38
/*
39
We do this because clock() is not affected by timeBeginPeriod on Win32.
40
QueryPerformanceCounter is a little overkill for the amount of precision that
41
I consider acceptable. If someone submits a patch that replaces this code
42
with QueryPerformanceCounter, I wouldn't complain. Until then, timeGetTime
43
gets the results I'm after. -EMS
44
45
See: http://www.geisswerks.com/ryan/FAQS/timing.html
46
And: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q274323&
47
*/
48
return
timeGetTime
();
49
#else
50
struct
timeval
now
;
51
gettimeofday
(&
now
,
nullptr
);
52
return
(
now
.tv_sec) * 1000 + (
now
.tv_usec) / 1000;
53
//return ( unsigned long )(( double )( clock() ) / (( double )CLOCKS_PER_SEC / 1000.0 ) );
54
#endif
55
}
56
57
}
// namespace MyGUI
MyGUI_Precompiled.h
MyGUI_Timer.h
MyGUI::Enumerator
Definition
MyGUI_Enumerator.h:49
MyGUI::Timer::reset
void reset()
Definition
MyGUI_Timer.cpp:25
MyGUI::Timer::Timer
Timer()
Definition
MyGUI_Timer.cpp:20
MyGUI::Timer::getMilliseconds
unsigned long getMilliseconds() const
Definition
MyGUI_Timer.cpp:30
MyGUI
Definition
MyGUI_ActionController.h:15
Generated by
1.9.8