Code: Select all
STMS() { ; System Time in MS / STMS() returns milliseconds elapsed since 16010101000000 UT
Static GetSystemTimeAsFileTime, T1601 ; By SKAN / 21-Apr-2014
If ! GetSystemTimeAsFileTime
GetSystemTimeAsFileTime := DllCall( "GetProcAddress", UInt
, DllCall( "GetModuleHandle", Str,"Kernel32.dll" )
, A_IsUnicode ? "AStr" : "Str","GetSystemTimeAsFileTime" )
DllCall( GetSystemTimeAsFileTime, Int64P,T1601 )
Return T1601 // 10000
} ; http://ahkscript.org/boards/viewtopic.php?p=17076#p17076
Values in milliseconds
In above test, elapsed time were simulated to be perfect increments of ms.ET QPC STMS ATC
1 1 1 0
2 2 2 0
3 3 3 0
4 4 4 0
5 5 5 0
6 6 6 15
7 7 7 0
8 8 8 16
9 9 9 0
10 10 10 16
11 11 11 15
12 12 12 16
13 13 13 0
14 14 14 15
15 15 15 16
16 16 16 16
17 17 17 15
18 18 18 16
19 19 19 16
20 20 20 16
21 21 21 15
22 22 22 31
23 23 23 16
24 24 24 31
25 25 25 16
26 26 26 31
27 27 27 31
28 28 28 31
29 29 29 16
30 30 30 31
31 31 31 31
32 32 32 32
33 33 33 46
34 34 34 32
35 35 35 31
36 36 36 31
37 37 37 47
38 38 38 31
39 39 39 47
40 40 41 31
41 41 41 47
42 42 42 47
43 43 43 31
44 44 44 47
45 45 45 46
46 46 46 47
47 47 47 47
48 48 48 47
49 49 49 47
50 50 50 46
51 51 51 63
52 52 52 47
53 53 53 46
54 54 55 63
55 55 55 47
56 56 56 62
57 57 57 62
58 58 58 47
59 59 59 63
60 60 60 62
61 61 62 62
62 62 62 63
63 63 63 62
64 64 64 63
65 65 65 62
66 66 66 62
67 67 67 78
68 68 68 63
69 69 69 78
70 70 70 62
71 71 71 78
72 72 72 63
73 73 73 78
74 74 74 78
75 75 75 62
76 76 76 78
77 77 77 78
78 78 78 78
79 79 79 78
80 80 80 78
81 81 81 94
82 82 83 78
83 83 83 78
84 84 84 93
85 85 85 78
86 86 86 94
87 87 87 78
88 88 88 93
89 89 89 94
90 90 90 78
91 91 91 94
92 92 92 93
93 93 93 94
94 94 94 93
95 95 95 94
96 96 96 94
97 97 97 93
98 98 98 109
99 99 99 94
In real world, elapsed time would be fractional and STMS() will err far more than above result, but up to 1 ms only.