Speed test

Miscellaneous Forums/General Discussion/Speed test

Here is a simple benchmark comparing c# speed of float to BlitzBasic speed of floats:

Blitz goes first. Here is the code:
For i = 1 To 5
startTime = MilliSecs()
c# = 0
While c# < 20000
c# = c# + .01
Wend
Print MilliSecs() - startTime
Next
WaitKey()

Results are as follows:
204
190
193
190
190
189


Now for the really slow c# (using low-res Environment.TickCount function) ;^)
static void floatTest()
{
for (int i = 0; i < 5; i++)
{
int startTime = Environment.TickCount;
float c = 0.0f;
while (c < 20000)
c = c + 0.01f;
Console.WriteLine(Environment.TickCount - startTime);
}
Console.ReadLine();
}

Results are:
15
31
16
16
15

C# is not slow. C# is not bad, and does not teach people to do crappy code. I write and maintain code full time in Delpi, C#, VB.Net, and sometimes C++ (Oh, yeah, and my first language was Commodore 64 Basic back in the 80s). C# is one of the most elegant languages I have ever worked with. However, crappy code can be written in any language.