Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/Time-a-function/PureBasic/time-a-function-3.basic
Normal file
30
Task/Time-a-function/PureBasic/time-a-function-3.basic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue