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

Function GetSystemTimer

sdk/tests/test_performance/source/utils.cpp:29–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29double GetSystemTimer()
30{
31 if( !timerInitialized )
32 {
33 // We need to know how often the clock is updated
34 __int64 tps;
35 if( !QueryPerformanceFrequency((LARGE_INTEGER *)&tps) )
36 usePerformance = false;
37 else
38 {
39 usePerformance = true;
40 ticksPerSecond = (double)tps;
41
42 __int64 ticks;
43 QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
44 performanceBase = (double)ticks/ticksPerSecond;
45 }
46
47 timerInitialized = true;
48 }
49
50 if( usePerformance )
51 {
52 __int64 ticks;
53 QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
54
55 double t = (double)ticks/ticksPerSecond - performanceBase;
56
57 // We need to calibrate the performance timer as it is known to jump from time to time
58 double t2 = (double)timeGetTime()/1000.0;
59 if( fabs(t-t2) > 0.1 )
60 {
61 performanceBase += t - t2;
62 t = t2;
63 }
64
65 return t;
66 }
67 else
68 return (double)timeGetTime()/1000.0;
69
70// return double(asINT64(GetCPUTime()))/10000000;
71}
72
73#else
74// Linux version

Callers 15

TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
TestFunction · 0.70
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