MyGUI
3.4.3
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
void
Timer::reset
()
21
{
22
mTimeStart = getCurrentMilliseconds();
23
}
24
25
unsigned
long
Timer::getMilliseconds
()
const
26
{
27
return
getCurrentMilliseconds() - mTimeStart;
28
}
29
30
unsigned
long
Timer::getCurrentMilliseconds()
const
31
{
32
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
33
/*
34
We do this because clock() is not affected by timeBeginPeriod on Win32.
35
QueryPerformanceCounter is a little overkill for the amount of precision that
36
I consider acceptable. If someone submits a patch that replaces this code
37
with QueryPerformanceCounter, I wouldn't complain. Until then, timeGetTime
38
gets the results I'm after. -EMS
39
40
See: http://www.geisswerks.com/ryan/FAQS/timing.html
41
And: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q274323&
42
*/
43
return
timeGetTime();
44
#else
45
struct
timeval now;
46
gettimeofday(&now,
nullptr
);
47
return
(now.tv_sec) * 1000 + (now.tv_usec) / 1000;
48
//return ( unsigned long )(( double )( clock() ) / (( double )CLOCKS_PER_SEC / 1000.0 ) );
49
#endif
50
}
51
52
}
// namespace MyGUI
MyGUI_Precompiled.h
MyGUI_Timer.h
MyGUI::Timer::reset
void reset()
Definition
MyGUI_Timer.cpp:20
MyGUI::Timer::getMilliseconds
unsigned long getMilliseconds() const
Definition
MyGUI_Timer.cpp:25
MyGUI
Definition
MyGUI_ActionController.h:15
Generated by
1.13.2