Anonymous user
Time a function: Difference between revisions
m
→Cleaned up and added documentation to the function using QueryPerformanceCounter
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 530:
=== Using QueryPerformanceCounter ===
QueryPerformanceCounter allows even more precision:
<lang AHK>MsgBox, %
TimeFunction(Function, Parameters*) {
SetBatchLines, -1 ; SetBatchLines sets the speed of which every new line of coe is run.
DllCall("QueryPerformanceCounter", "Int64*", CounterBefore) ; Start the counter.
DllCall("QueryPerformanceFrequency", "Int64*", Freq) ; Get the frequency of the counter.
Function.Call(Parameters*) ; Call the function with it's parameters.
DllCall("QueryPerformanceCounter", "Int64*", CounterAfter) ; End the counter.
return (CounterAfter-CounterBefore)/Freq * 1000 " milliseconds"▼
; Calculate the speed of which it counted.
}
fx() {
Sleep, 1000
}</lang>
|