Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Time-a-function/PureBasic/time-a-function-1.basic
Normal file
22
Task/Time-a-function/PureBasic/time-a-function-1.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Procedure Foo(Limit)
|
||||
Protected i, palindromic, String$
|
||||
For i=0 To Limit
|
||||
String$=Str(i)
|
||||
If String$=ReverseString(String$)
|
||||
palindromic+1
|
||||
EndIf
|
||||
Next
|
||||
ProcedureReturn palindromic
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
Define Start, Stop, cnt
|
||||
PrintN("Starting timing of a calculation,")
|
||||
PrintN("for this we test how many of 0-1000000 are palindromic.")
|
||||
Start=ElapsedMilliseconds()
|
||||
cnt=Foo(1000000)
|
||||
Stop=ElapsedMilliseconds()
|
||||
PrintN("The function need "+Str(stop-Start)+" msec,")
|
||||
PrintN("and "+Str(cnt)+" are palindromic.")
|
||||
Print("Press ENTER to exit."): Input()
|
||||
EndIf
|
||||
14
Task/Time-a-function/PureBasic/time-a-function-2.basic
Normal file
14
Task/Time-a-function/PureBasic/time-a-function-2.basic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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 Droopy-library
|
||||
If MeasureHiResIntervalStart()
|
||||
; Same Foo() as above...
|
||||
cnt=Foo(1000000)
|
||||
Timed=MeasureHiResIntervalStop()
|
||||
EndIf
|
||||
PrintN("The function need "+StrF(Timed*1000,3)+" msec,")
|
||||
PrintN("and "+Str(cnt)+" are palindromic.")
|
||||
Print("Press ENTER to exit."): Input()
|
||||
EndIf
|
||||
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