31 lines
853 B
Plaintext
31 lines
853 B
Plaintext
Procedure.f ticksHQ(reportIfPresent = #False)
|
|
Static maxfreq.q
|
|
Protected T.q
|
|
If reportIfPresent Or maxfreq = 0
|
|
QueryPerformanceFrequency_(@maxfreq)
|
|
If maxfreq
|
|
ProcedureReturn 1.0
|
|
Else
|
|
ProcedureReturn 0
|
|
EndIf
|
|
EndIf
|
|
QueryPerformanceCounter_(@T)
|
|
ProcedureReturn T / maxfreq ;Result is in milliseconds
|
|
EndProcedure
|
|
|
|
If OpenConsole()
|
|
Define timed.f, cnt
|
|
PrintN("Starting timing of a calculation,")
|
|
PrintN("for this we test how many of 0-1000000 are palindromic.")
|
|
; Dependent on Windows API
|
|
If ticksHQ(#True)
|
|
timed = ticksHQ() ;start time
|
|
; Same Foo() as above...
|
|
cnt = Foo(1000000)
|
|
timed = ticksHQ() - timed ;difference
|
|
EndIf
|
|
PrintN("The function need " + StrF(timed * 1000, 3) + " msec,")
|
|
PrintN("and " + Str(cnt) + " are palindromic.")
|
|
Print("Press ENTER to exit."): Input()
|
|
EndIf
|