MCPcopy Create free account
hub / github.com/anjo76/angelscript / GetSystemTimer

Function GetSystemTimer

sdk/tests/test_build_performance/source/utils.cpp:11–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9bool usePerformance = false;
10double performanceBase = 0;
11double GetSystemTimer()
12{
13 if( !timerInitialized )
14 {
15 // We need to know how often the clock is updated
16 __int64 tps;
17 if( !QueryPerformanceFrequency((LARGE_INTEGER *)&tps) )
18 usePerformance = false;
19 else
20 {
21 usePerformance = true;
22 ticksPerSecond = (double)tps;
23
24 __int64 ticks;
25 QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
26 performanceBase = (double)ticks/ticksPerSecond;
27 }
28
29 timerInitialized = true;
30 }
31
32 if( usePerformance )
33 {
34 __int64 ticks;
35 QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
36
37 double t = (double)ticks/ticksPerSecond - performanceBase;
38
39 // We need to calibrate the performance timer as it is known to jump from time to time
40 double t2 = (double)timeGetTime()/1000.0;
41 if( fabs(t-t2) > 0.1 )
42 {
43 performanceBase += t - t2;
44 t = t2;
45 }
46
47 return t;
48 }
49 else
50 return (double)timeGetTime()/1000.0;
51}
52

Callers 7

TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70

Calls 1

timeGetTimeFunction · 0.50

Tested by

no test coverage detected