Time cost of simple function/method calls

BlitzMax Forums/BlitzMax Programming/Time cost of simple function/method calls

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I thought that using 'final' should speed things up just a bit.
but it actually slows it down a little. Strange....

change the default value of 'Somefield' and see the difference..

SuperStrict

Global t:tMyType = New tMyType
Global t2:tMytype2 = New tMytype2

Global n:Int
Global s:Int

s = MilliSecs()
For n = 1 To 1000000
   t.DoStuff()
Next
s = MilliSecs() - s
Print "First test: " + s + "ms"

s = MilliSecs()
For n = 1 To 1000000
   t.DoStuff2()
Next
s = MilliSecs() - s
Print "Second test: " + s + "ms"
'End

Print "Final"

s = MilliSecs()
For n = 1 To 1000000
   t2.DoStuff()
Next
s = MilliSecs() - s
Print "First test: " + s + "ms"

s = MilliSecs()
For n = 1 To 1000000
   t2.DoStuff2()
Next
s = MilliSecs() - s
Print "Second test: " + s + "ms"
End




Type TMyType
	
	Field somefield:Int '= 1
		
		Method GetSomeField%()
			
			Return somefield 
			
		End Method
		
		Method DoStuff:String()
			
			Return (Pi * GetSomeField() + " " + GetSomeField())
			
		End Method
		
		
		Method DoStuff2:String()
			
			Return (Pi * somefield + " " + somefield)
			
		End Method
End Type



Type TMyType2 Final
	
	Field somefield:Int '= 1
		
		Method GetSomeField%() Final
			
			Return somefield 
			
		End Method
		
		Method DoStuff:String() Final
			
			Return (Pi * GetSomeField() + " " + GetSomeField())
			
		End Method
		
		
		Method DoStuff2:String() Final
			
			Return (Pi * somefield + " " + somefield)
			
		End Method
End Type