little Benchmark

BlitzMax Forums/BlitzMax Programming/little Benchmark

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.

sorry guys but you can't compare the time because you don't have the comparison codes. So, if I would run my code on my new pc it would probably only take 2 secs or less. These are my testing specs: winxppro sv2 Pentium 4/2.67 GHz and 1GB Ram

@ziggy: for c# or vb you have to declare and define AND actually use these variables or else it will get optimized, meaning it won't calculate at all. I got the same result as you the first time, then I added an editfield which showed me the result of x after the loop. C# was the only language optimizing in such a way.
Edit: Why are x,y integers? They are doubles at least should be -> Azathoth

@Azathoth: true, changed it, now it takes 7,54 secs with pb....

and yes, hopping to so many languages let me tripple about it, in BMax I have to declare each type separately ;) thanks for pointing this out. It's only in BMax that way. Now it takes only 11,67 secs.

Here the new code.
SuperStrict

Global Anzahl : Long,Iterationen : Long,EndTime : Long,StartTime : Long,i : Long
Global  DauerMsec: Double,x : Double,y : Double

Anzahl  =  Long ( Input("Anzahl Clients: "))
Iterationen = ((Anzahl-1)*Anzahl/2)

EndTime = MilliSecs()

For i = 0 To Iterationen
	y = Sin(i)
	x = Cos(y)
	x = x*y
Next
StartTime = MilliSecs()
Print "Anzahl: " + String(Anzahl)
Print "Iterationen: " + String(Iterationen)

DauerMsec = StartTime - EndTime

Print "Millisekunden: " + String.FromDouble(DauerMsec)
Print "Sekunden: " + String.FromDouble(DauerMsec/1000)


@tonyg: i must be as big as iterations

@Grisu: helpful

So BlitzMax is getting nearly as fast as c#. Now I would like to know why. Just to understand the 'under the hood'. Always eager to learn... (I still would have bet that pb and BMax would be equally fast in math)