MAX v Blitz2D: Speed

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

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.