Code archives/Miscellaneous/Function Speed

This code has been declared by its author to be Public Domain code.

Download source code

Function Speed by Malice
(Posted 24 years ago)
Use this and include your own functions to find out how quickly they run. Useful for comparing different ways of doing something.
;Malice's Function Timer
;Please note Although this includes drawing speed to frontbuffer, the main idea is to test the speed
;of mathematical And logical processes.








;Use Input or substitute loop=xxxxx The greater the value, the more accurate result although longer
;Functions may be better tested with a smaller loop.


loop#=Input()
;Sets basic time for for/next and setting timer

control_timer#=MilliSecs()
For f=1 To loop#
Next
control_timer#=(MilliSecs()-control_timer#)

;now to find time of function

function_timer#=MilliSecs()

For g=1 To loop#

;Either use Inclde (as this example) or copy/paste your function HERE
Include "Function.bb"

Next

function_timer#=MilliSecs()-function_timer#

time#=((function_timer#-control_timer#)/loop#)

Cls
t$=" Milliseconds"
If time#>60000 Then t$="Minutes" time#=time#/60000
If time#>1000 Then t$="Seconds" time#=time#/1000
If time<1 Then t$=" (Negligible: less than 1 millisecond)"

Text 10,100,time#+" "+t$


WaitKey

End