Function Execution speed

BlitzPlus Forums/BlitzPlus Programming/Function Execution speed

I'm looking for that thing in the code archives that figured out how long it took for a function to execute, but I don't even remember where it was. Anyone got the link?

start% = Millisecs()
MyFunction()
DebugLog "Function took " + (Millisecs() - start) + "ms to execute"

Function MyFunction()
  ;Do stuff here
End Function


Also, if the function is very quick, that might not be quite good enough so, record the start time, then call the function say 100 or 1000 times in a for loop, and output the time afterwards. This works well.

Make sure your functions aren't calling flip as that will take ages and not give a valid time taken reading.

using flip 0 instead of just flip speeds it up.

adding 'false' forces a flip straight away as opposed to waiting for a vb.

btw GFk, what is the % for after the variable start?

flip0 will still slow it down a bit as the graphics are rendered to the video card. Basically for timing functions, don't have flip in them (unless you are timing a draw function on prupose).

The % means the variable is an integer. Actually all variables are integer by default so it's not required, however, it can help to clarify sometimes.

ahhh thx Grey :)