MAX v Blitz2D: Speed

BlitzMax Forums/BlitzMax Beginners Area/MAX v Blitz2D: Speed

Has anybody done a MAX v Blitz 2D speed comparison? I searched for one but couldn't find anything on it.

It's a bit tricky without knowing in which context.
This might help...
Performance1
A few people have had performance issues with certain drivers and amount of RAM...
Performance2
Performance3

Since BlitzMax allows for flexibility, you have to be real carefull how you're handling the images. The only BMax app/demo that really crapped out my old laptop(ATI 16 mb mobility m4 on my p3 800 mhz, 384mb ram) was this chess game someone was writing a while back. Otherwise, everything I ran, and the current game I'm building - which is image/graphic intensive - runs just fine on my system.

Has anybody done a MAX v Blitz 2D speed comparison?
Several. Neither are particularly conclusive tho'.

The short version is that BlitzMAX has more optimizations, and a better compiler, so "raw" operation output should be faster, if for no other reason, then because of better register utilization.

Things that rely heavily on stdc functionality could be slower, depening on how you use them.

Also keep in mind that OOP generally adds a slight overhead.

The question you really should be asking yourself however is a different one: Who really cares? Most people favor short development times over raw speed anyway, and in BlitzMAX game development time is rediculously fast. So what if it only runs at 170 fps (as opposed to 200)?

So blitzmax is slower?

No, If you use the OOP correctly then Blitzmax is faster then Blitz2d. The non OOP Commands are easier to implement but slow Bmax down.
Don't know if this complete correctly. but this is my Experience.

So blitzmax is slower?
Not universally no. It depends on what you're doing with it. You could write examples that prove both. It's like comparing Apples and Oranges. In general the object overhead is cancled out by compiler optimizations.

I've recently ported my crossblend function to BlitzMAX, and while it's still not very optimized (by a long shot), it's noticably faster than on both Blitz2D and BlitzPlus.

Some tests you can try for yourself ...


This zip includes source + exe for BlitzMax , Blitz3D, C++, and Pure Basic.

Sieve Speed Tests

Anyone fancy doing other versions such as C++ (source+exe) ?

Here's the Max code
' BlitzMax sieve test

Framework BRL.StandardIO
Import BRL.System

Const ITERATIONS=50000

Print("SIEVE OF ERATOSTHENES - "+ITERATIONS+" iterations")

Global t=MilliSecs()

For Local Iter = 1 To ITERATIONS

	Local flags[8191],i,k,prime
	Local Count = 0

	For i = 0 To 8190
    	flags[i] = 1
	Next

	For i = 0 To 8190
		If flags[i]=1
			prime=i+i
			prime=prime+3
			k=i+prime
			While k <= 8190
				flags[k] = 0
				k=k+prime
			Wend
			count=count+1
		EndIf
	Next

	FlushMem

Next

t=MilliSecs()-t
Print ITERATIONS+" iterations took "+t+" m/secs."
Print "Primes: "+Count
Input "Return to end ..."
End


I'm finding (after several runs of each) that the Max version is 1.7 times faster than the Pure Basic version and over 20 times faster than the Blitz3D version. Woosh!


That Max version runs 25 times faster than the B3D on my computer... 2.5 times as fast as PureBasic.

Um... doesn't that have something to do with the fact, that the MaxDemo performs 5000 iterations while the b3dDemo has to do 50000 Iterations?

I think in my own tests it was nearly twice as fast as Blitz3D and 0.8 times as fast as C++.

Max version is about twice as fast as B3D version. As DocFritz pointed out, one has to change the number of iterations to 5000 in B3D to make this a proper comparison.

Barney

Oops. Updated zip (all versions running 50000 iterations).

Now shows Max version to be:

1.79 times quicker than Blit3D version
1.72 times quicker than Pure Basic version

Heh, didn't catch that either.

Now shows (50,000 iterations)

BlitzMax: 4460
Blitz3D: 12006
PureBasic: 11112

...making Blitzmax sample 2.69 times as fast as B3D and 2.49 times as fast as PureBasic on my computer.

JB: Are you running Intel or AMD? That could account for some of the speed differences between our results as well, since some of executables may be more optimized towards one platform than the other.

Intel P4 3.6Ghz (with Hyper Threading).

Here is some reference code in C++:
#include <iostream>
#include <ctime>
#include <conio.h>

int main(int argc, char* argv[])
{
	int const ITERATIONS = 50000;
	std::cout << "SIEVE OF ERATOSTHENES - " << ITERATIONS << " iterations\n";
	int cps = CLOCKS_PER_SEC / 1000;
	long t = std::clock();
	int Count;

	for(int Iter = 1; Iter <= ITERATIONS; Iter++)
	{
		int flags[8191];
		int i = 0;
		int k = 0;
		int prime = 0;
		Count = 0;
		
		for (i = 0; i <= 8190; i++)
		{
			flags[i] = 1;
		}

		for (i = 0; i <= 8190; i++)
		{
			if (flags[i] == 1)
			{
				prime = i + i;
				prime = prime +3;
				k = i + prime;
				while (k <= 8190)
				{
					flags[k] = 0;
					k = k + prime;
				}
				Count = Count + 1;
			}
		}
	}
	t = std::clock() - t;
	t = t / cps; // because there might be more than 1000 CLOCKS_PER_SECOND
	std::cout << ITERATIONS << " iterations took " << t << " millisecs.\n";
	std::cout << "Primes found: " << Count << "\n";
	std::cout << "Any key to end ...";
	getch();
}

And a zip with a binary for those without MinGW. The results for the TabletPC are rather interesting:

C++ Reference: 9.6 secs
BlitzMAX: 11.2 secs
Blitz3D: 17.7 secs
PureBasic: 18.9 secs

So Blitz3D and PureBasic are nearly equally fast, BlitzMAX is nearly twice as fast, and C++ is marginally faster than that.

Added to my zip.
Very interesting. Max is certainly hot on the heels of C++.

Any other versions?

Heh...just for sh*ts and giggles, lets have someone who will admit they have Dark Basic Pro give it a whirl and see what times they get...

I ported the code to VB.NET. My times are as follows:

C++ reference: 3.437 secs
BlitzMAX: 4.008 secs
Blitz3D: 10.524 secs
PureBasic: 10.531 secs
VB.NET: 7.853 secs

Tests were performed on an Athlon 64 3500+