how fast to 1 Billion ?

BlitzMax Forums/BlitzMax Beginners Area/how fast to 1 Billion ?

How fast does your BMAX system count to 1 billion?

sample code:
[code box]
Strict

Global a:Int = 0

Global start:Int = MilliSecs(),finish:Int

While( a < 1000000000)

a = a + 1

Wend

finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"

[/code box]

see if I can do this code bos thing right

Strict 

Global a:Int = 0 

Global start:Int = MilliSecs(),finish:Int 

While( a < 1000000000) 

a = a + 1 

Wend 

finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds" 


Here is the result with my system

Process complete
C:/BlitzMax/BlitzMaxCore104/tmp/untitled1.exe
0 to 1 Billion in 5875 milliseconds

Process complete

This is great ... and old c++ compiler (borland ver 4.52)
I compilied a test for was running 7 seconds.

Ran a C++ compiled program at work on a linux system
we have which are dual 3.2Gig Xeon processors that
cranked out 0 - 1.0e+9 in .6 seconds

With my slow system it took:
0 to 1 Billion in 125833 milliseconds

PII 400mhz/256mb ram/geforce4 mmx 460

I got

0 to 1 Billion in 18543 milliseconds

DEBUG ON

AthlonXP3000(@...) 512ram
Radeon9600 256meg

I got

Process complete
C:/BlitzMax/tmp/untitled1.exe
0 to 1 Billion in 1723 milliseconds

Process complete

P4 2.4 ghz
512ram

0 to 1 Billion in 2368 milliseconds (normal)

0 to 1 Billion in 19334 milliseconds (debug, what a difference!)

p4 HT 3ghz, 512mb
(office pc, so maybe there are some less-than-optimal components alltough the proc is quite cool... i'm at work now)

0 to 1 Billion in 2952 milliseconds on Athlon 2800+

jojo... I would think you must have been in debug mode with that slow of time, Turn off debug and see if you get a better time, I would be interested in what you get with debug off too Col :)

You're slowing yourself down there using Globals when they're not needed. ;)

Try this:
Strict 

Local a:Int = 0 

Local start:Int = MilliSecs(),finish:Int 

While( a < 1000000000) 

a = a + 1 

Wend 

finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds" 

My machine: Dell Latitude C840, Windows XP SP2, 1.8GHz P4, 768MB Mem

Original version:
Debug mode: 33132ms
NoDebug mode: 2340ms

Local variable version:
Debug mode: 34155ms
NoDebug mode: 876ms

Muttley

Anybody think they can beat those dual Xeon processors
that cranked out (C++ code) a blistering 680 milliseconds

... ah technology today -- think about it ... counting to

1 billion before you could say the word 'one'

Local did drop me another 2.5 seconds on my 1Ghz Athlon

Process complete
C:/BlitzMax/BlitzMaxCore104/tmp/untitled1.exe
0 to 1 Billion in 3114 milliseconds

Process complete

Thanks,

what I dont understand is why my old borland C++ compilier
is taking 7 seconds ... I have all the optimized settings set as far as I know and her is the code.

[codebox}
#include <iostream.h>
#include <time.h>

int main()
{
long a = 0;
int seconds = 0;
time_t start,end;
cout << "Staring my count to 1 billion\n";
start = time(NULL);

do
{
a++;
} while (a < 1000000000);

end = time(NULL);
seconds = end - start;
cout << "0 to 1 billion is complete in " << seconds << " seconds\n";
return 0;
}
[/codebox]

anyway from the looks of it ... BMAX is great :)

btw, you can edit your posts. See the top right of each posting, there is an "edit" link.

Here is my result
0 to 1 Billion in 602 milliseconds


Strict adds overhead
compiler defaults to int
for/next faster then while/wend
calculate before print


 
Local start = MilliSecs(), a = 0, finish

For a = 0 To 1000000000 ; Next

finish = (MilliSecs() - start)

Print "0 to 1 Billion in " + finish + " milliseconds"


Enjoy

Compiling:untitled1.bmx
Linking:untitled1
Executing:untitled1
0 to 1 Billion in 5092 milliseconds
Done.

on a 700mhz g4 imac

Thanks to the suggestion of using GLOBAL variables instead of LOCAL ones I got the idea of optimizing this loop a little further. I read somewhere that FOR .. = .. UNTIL .. would be faster than using FOR .. = .. TO .., so I figured this might apply to other loops as well. Also we can do x:+1 instead of x = x + 1. I put it all togehter in a (rather dirty, I admit) program, and the results were quite interesting.

I will refer to FOR .. = .. TO .. / NEXT as FOR-TO and to FOR .. = .. UNTIL .. / NEXT as FOR-UNTIL from here on.

Here are the GLOBAL vs LOCAL results:

WHILE loop and x = x + 1...
LOCAL: 548 milliseconds
GLOBAL: 2374 milliseconds

REPEAT loop and x = x + 1...
LOCAL: 545 milliseconds
GLOBAL: 2365 milliseconds

WHILE loop and x :+ 1...
LOCAL: 514 milliseconds
GLOBAL: 2032 milliseconds

REPEAT loop and x :+ 1...
LOCAL: 816 milliseconds
GLOBAL: 2034 milliseconds

FOR-TO loop
LOCAL: 524 milliseconds
GLOBAL: 2023 milliseconds

FOR-UNTIL loop...
LOCAL: 512 milliseconds
GLOBAL: 2039 milliseconds

As it was already stated GLOBAL variables are *very much* slower than LOCAL ones.


I will now compare the different aspects in the WHILE and REPEAT loops.
These are the same results as before (exept FOR/NEXT loops), but grouped otherwise to make it easy to compare the difference between x = x + 1 and x:=1

Using LOCAL, WHILE loop
x=x+1: 548 milliseconds
x:+1: 514 milliseconds

Using GLOBAL, WHILE loop
x=x+1: 2374 milliseconds
x:+1: 2032 milliseconds

Using LOCAL, REPEAT loop
x=x+1: 545 milliseconds
x:+1: 816 milliseconds

Using GLOBAL, REPEAT loop
x=x+1: 2365 milliseconds
x:+1: 2034 milliseconds

You can see that using the shortcut (x:+1) is a bit faster than the old way, except for the LOCAL, REPEAT-loop thingy. This is a bit weird, but of course anything may be influenced by other processes. There were no programs active when I ran this test, but windows keeps a lot of background processes. It might be a nice thing to run this test several times to get a better avarage.

The first time I ran this thing I had one process taking up 100% of one virtual processor (p4 HT) and then the x:+1 was more than twice as fast! Don't know what exactly causes this.


Next thing up is the comparisation between WHILE and REPEAT loops. Of couse I'm using the same results.

Using LOCAL and x = x + 1...
WHILE: 548 milliseconds
REPEAT: 545 milliseconds

Using GLOBAL and x = x + 1...
WHILE: 2374 milliseconds
REPEAT: 2365 milliseconds

Using LOCAL and x :+ 1...
WHILE: 514 milliseconds
REPEAT: 816 milliseconds

Using GLOBAL and x :+ 1...
WHILE: 2032 milliseconds
REPEAT: 2034 milliseconds

As you see there is not much difference, exept for the LOCAL and x:+1. This result showed odd earlier.

Now we got the WHILE and REPEAT loops finished, let's see how the FOR loops behave!

Since we've already seen the difference between GLOBAL and LOCAL variables the only thing left to compare is FOR-TO and FOR-UNTIL. Behold:

Using LOCAL variables
FOR-TO: 524 milliseconds
FOR-UNTIL: 512 milliseconds

Using GLOBAL variables
FOR-TO: 2023 milliseconds
FOR-UNTIL: 2039 milliseconds

There is no clear difference between these two, but the difference that there is is rather small.


As a last thing to compare I have for you are all the results, ordered by speed.

Using LOCAL, FOR-UNTIL loop: 512 milliseconds
Using LOCAL, WHILE loop and x :+ 1: 514 milliseconds
Using LOCAL, FOR-TO loop: 524 milliseconds
Using LOCAL, REPEAT loop and x = x + 1: 545 milliseconds
Using LOCAL, WHILE loop and x = x + 1: 548 milliseconds
Using LOCAL, REPEAT loop and x :+ 1: 816 milliseconds
Using GLOBAL, FOR-TO loop: 2023 milliseconds
Using GLOBAL, WHILE loop and x :+ 1: 2032 milliseconds
Using GLOBAL, REPEAT loop and x :+ 1: 2034 milliseconds
Using GLOBAL, FOR-TO loop: 2039 milliseconds
Using GLOBAL, REPEAT loop and x = x + 1: 2365 milliseconds
Using GLOBAL, WHILE loop and x = x + 1: 2374 milliseconds

The conclusion so-far is rather easy: use FOR-UNTIL where possible ;)

These results are, however, statistically of not-so-much use, because it was just one test I ran. If I can find some time tonight (now I really need to get back to my database since I don't suppose my boss would like to see me toying with blitz all day ;) ) to do this more properly.

Of couse I won't let you go home without some source. It's a bit dirty and hastly-done, but clear.


Rem

	this is a rather dumb but interresting example to benchmark various ways to do loops 
	the loops differ on the following subjects:
	
	- the use of LOCAL and GLOBAL variables
	- WHILE .. / WEND or REPEAT / UNTIL .. loops
	-  in case of WHILE / WEND or REPEAT / UNTIL loops the use of
	   the old-fashioned x = x + 1 or the new shortcut x:+ 1
	- FOR .. = .. TO .. / NEXT or FOR .. = .. UNTIL .. / NEXT loops
	
	it is of course based on the benchmark that this topic started with and
	a few suggestions that were made.

EndRem

Strict 

Local l:Int = 0 					'l for local loop
Global g:Int = 0					'g for global loop
Local finish:Int					'moved finish declaration up so it won't consume any ticks while benchmarking
Local start:Int					'split declaration and the assigning of millisecs() so it looks a bit cleaner


'local variable, while loop, x = x + 1
Print "Using LOCAL, WHILE loop and x = x + 1..."

start = MilliSecs()
While (l < 1000000000) 
 l = l + 1 
Wend 
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'global variable, while loop, x = x + 1
Print "Using GLOBAL, WHILE loop and x = x + 1..."

start = MilliSecs()
While (g < 1000000000) 
 g = g + 1 
Wend 
finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"
Print


l = 0	'reset variables
g = 0


'local variable, repeat loop, x = x + 1
Print "Using LOCAL, REPEAT loop and x = x + 1..."

start = MilliSecs()
Repeat 
 l = l + 1 
Until (l = 1000000000)
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'global variable, repeat loop, x = x + 1
Print "Using GLOBAL, REPEAT loop and x = x + 1..."

start = MilliSecs()
Repeat 
 g = g + 1 
Until (g = 1000000000) 
finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"
Print


l = 0	'reset variables
g = 0


'local variable, while loop, x :+ 1
Print "Using LOCAL, WHILE loop and x :+ 1..."

start = MilliSecs()
While (l < 1000000000) 
 l:+ 1 
Wend 
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'global variable, while loop, x :+ 1
Print "Using GLOBAL, WHILE loop and x :+ 1..."

start = MilliSecs()
While (g < 1000000000) 
 g:+ 1 
Wend 
finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"
Print


l = 0	'reset variables
g = 0


'local variable, repeat loop, x :+ 1

Print "Using LOCAL, REPEAT loop and x :+ 1..."

start = MilliSecs()
Repeat 
 l :+ 1 
Until (l = 1000000000)
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'global variable, repeat loop, x :+ 1

Print "Using GLOBAL, REPEAT loop and x :+ 1..."

start = MilliSecs()
Repeat 
 g :+ 1 
Until (g = 1000000000)
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'start for/next loops


'local variable, for-to loop
Print "Using LOCAL, FOR-TO loop"

start = MilliSecs()
For l = 0 To 1000000000
Next
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'global variable, for-to loop

Print "Using GLOBAL, FOR-TO loop..."

start = MilliSecs()
For g = 0 To 1000000000
Next
finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"
Print


'local variable, for-until loop
'because this is an until-loop, we need to loop until 1000000000 + 1 to be precise

Print "Using LOCAL, FOR-UNTIL loop..."

start = MilliSecs()
For l = 0 Until 1000000001
Next
finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  
Print


'global variable, for-until loop, x = x + 1
'because this is an until-loop, we need to loop until 1000000000 + 1 to be precise

Print "Using GLOBAL, FOR-TO loop..."

start = MilliSecs()
For g = 0 Until 1000000001
Next
finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"
Print



gameking: thanks for your suggestions, I will use them when I continue testing, alltough calculating before print and the declaration won't influence these benchmarks of course, because they happen 'outside' the time-tested code.
If 'strict' add overhead while executing I can't tell, but it's worth a try :)

Interesting, didnt know Local vs. Global does make such a difference.
What about do the same but in a function and call that function a billion times.
Local is then generated and killed every function call?
If so, maybe its slower using locals?
Just a dumb question..

Takuan: of course that is slower, because there is much overhead. first you call a function, which creates a new local variable and then distroys it and then must return to the main program.
I wonder however how you would implement this test which actually does the same thing but requires such a function to do it's job..

local l:int

while(l<1000000000)
  l = update(l)
wend

function update(i:int)
  local j = 1
  return i + j
endfunction


that doesnt compare to the other way people tried before in this topic

however, of course we can benchmark this whole variable construction/destruction thing:


Local start:Int
Local finish:Int
Local i:Int


start = MilliSecs()
For i = 0 To 1000000000
  func_with_var
Next
finish = MilliSecs()

Print finish-start

start = MilliSecs()
For i = 0 To 1000000000
  func_without_var
Next
finish = MilliSecs()

Print finish-start

Function func_with_var()
  Local dummy = 1
EndFunction

Function func_without_var()
EndFunction



This actually gives some odd results to me, the left column is the time of calling the function with the variable, the right column is the time of calling the other (empty) function. And I'm really not mistaken... anyone can shine any light on this?

6031 - 6731
6211 - 7305
6119 - 7256
6026 - 6817
6029 - 6992

edit: maybe I misunderstood you and were you wondering how a function which creates a local variable would compare with another function which calls a global variable. Got these results:

left = local var, mid = global var, right = no var

6059 - 6856 - 6789
6614 - 6689 - 6677
6002 - 6699 - 6830
6625 - 6779 - 6736
6000 - 7277 - 6665

Local start:Int
Local finish:Int
Local i:Int

Global g:Int

For cnt = 1 To 5

start = MilliSecs()
For i = 0 To 1000000000
  func_with_l_var
Next
finish = MilliSecs()

Print finish-start

start = MilliSecs()
For i = 0 To 1000000000
  func_with_g_var
Next
finish = MilliSecs()

Print finish-start

start = MilliSecs()
For i = 0 To 1000000000
  func_without_var
Next
finish = MilliSecs()

Print finish-start

Print 
Next
End

Function func_with_l_var()
  Local dummy = 1
EndFunction

Function func_with_g_var()
  g = 1
EndFunction

Function func_without_var()
EndFunction


Thanks on the note on how to edit... not sure why but I
wasn't seeing the edit link but now I am.. I definitiely need it because my fat fingers always get in the way and my brain obviously doen't know how to control them.

I get 1288 ms
Using Muttley's version I get 492 ms.

Pentium 4 HT, 3.2Ghz 1024Mb RAM

To make it more accurate, you should put a delay at the beginning.

Strict 

Local a:Int = 0 

Local start:Int 
Local finish:Int 

Delay 500

start = MilliSecs()

While( a < 1000000000) 

a = a + 1 

Wend 

finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  


Curious as to whether or not blitzmax does this any faster than Blitz3d.

I do not have blitzmax, but I get 1778 with blitz3d

Work machine: (wish it was home machine)
Dual 3.4 Xeon
4Gig Ram

and what did you get with bmx then? would be way easier to compare if you posted that as well :)

I gert between 0 to 1 Billion in 2713 and 2834 milliseconds without debug in the various versions of code I tried. That was on a 4 year old Athlon 1200

Rod49:

Using the first program in this thread, I got-
0 to 1 Billion in 1514 milliseconds

with DEBUG OFF. Blimey!!

And using the program by GameKing:
0 to 1 Billion in 995 milliseconds
DEBUG OFF
Nice.

And the code by Coorrae:
0 to 1 Billion in 974 milliseconds
DEBUG OFF

using coorea's which is the most accurate I get 918 on my new comp i built last week <:-)

AMD Athalon64 3500+
1GB HyperX RAM
Radeon X700 Pro 256mb

how fast to a billion? Gimme a few years and I'll make it... $:-)$

Ok, did it with debug off.
0 to 1 Billion in 18151 milliseconds

PII 400mhz 128mb ram

Building untitled1
Compiling:untitled1.bmx
flat assembler version 1.51
3 passes, 2332 bytes.
Linking:untitled1.exe

Process complete
K:/BMAX/tmp/untitled1.exe
0 to 1 Billion in 3959 milliseconds

Process complete

how fast to a billion? Gimme a few years and I'll make it... $:-)$

Of course you will then remember how I've always been your very best friend and such, right? =P

Of course, my friend, now get back working!

work means cash... see if I get there first $-)

0 to 1bil in 1015 millesecs (normal)
0 to 1bil in 18476 millesecs (debug)

wow what a difference!

Dual 2ghz G5

From Coorrea code:

Debug off
0 to 1 Billion in 5189 milliseconds

Debug on
0 to 1 Billion in 118419 milliseconds

PII 400 mhz 256mb ram

Well this turned out to be an interesting link to see all the difference in times by machines etc...

thanks for all the input.

I thought my computer was really slow at first but the 2nd modification ran at 623millisecs!

Macintosh duel G4

3065 secs in Bmx with this prog:

start=MilliSecs()
For i=0 To 1000000000
Next
finish=MilliSecs()-start
Print finish
End


0 to 1 Billion in 3708 milliseconds

I didn't expect a good result like that from my laptop.

Windows XP Sp1 (Sp2 is annoying)
Intel Pentium 4m 1.3GHz
256MB SDRAM
ATi Mobility Radeon 9000 (64MB VRAM)

0 to 1 Billion in 4073 milliseconds (norm)
0 to 1 Billion in 28799 milliseconds (debug)

Rich your system is cool *rofl*

1454 ms norm
5112 ms debug

Pentium - M ( 1.5 Ghz, old P-M with 1MB 2nd lvl cache )

Using Coorrae's code:

0 to 1 Billion with debug ON: 26165 milliseconds
0 to 1 Billion with debog OFF: 725 milliseconds

I did this test on a friends' computer lateley and he wrote the same thing in c++. I don't remember the exact details of what we did but I think it was a for-to loop and using local integers. He turned on al optimization options for his compiler (don't know which) (of course he did, it'd be stupid to leave them off right?) and c++ turned out to be 10-20 millisecs faster than bmx. total time was about 2500ms.

'Original code
0 to 1 Billion in 15162 milliseconds
'With locals
0 to 1 Billion in 5034 milliseconds
'With locals and a for-next loop
0 to 1 Billion in 5409 milliseconds
'With locals and a repeat-until a=1000000000
0 to 1 Billion in 5208 milliseconds

Gave up on debug mode, as it was easily taking over a minute (?!?!?)

700mhz G4 iMac

I wonder why while wend is faster than the other loops...



@Rich A Dual G4 what?

Using Coorrae's code:

Building untitled2
Executing:untitled2.exe
0 to 1 Billion in 462 milliseconds

Process complete

P4/ 3.4Ghz

I got 550 with Muttley's code

0 to 1 Billion in 793 milliseconds

System: XP 2.09 GHz, 1 GB Ram

using this code:


Strict

Local start:Int = MilliSecs(),finish:Int

For Local a:Int = 0 Until 1000000000
a:+1
Next

finish = MilliSecs()

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"

0 to 1 Billion in 548 milliseconds

Looks like p4 of 3ghz and above are very,very fast. ;)

p4, 3.2Ghz, 1GB dual channel RAM

Ok, I've optimized the code....

Strict 

Local start:Int = MilliSecs(),finish:Int 

For Local a:Int = 0 Until 1000000000
a:+1000000000 
Next

finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds" 


Does it in 0 Milliseconds...

Original code, 10467 millisecs. Mac osX panther 1GHz G4 256mb ram


I also got 3498 millisecs with muttley's version

With arcadenut's version, adding 1 each loop not a billion, I get 1734 millisecs.

With Rod49s original code, I get:

0 to 1 Billion in 39684 milliseconds (Debug)
0 to 1 Billion in 17584 milliseconds (Release)

Using Muttley's "Local Variable" version, I get:

0 to 1 Billion in 39262 milliseconds (Debug)
0 to 1 Billion in 1308 milliseconds (Release)

Are these numbers correct? They seem weird compared to the others on here.

Mac OS X 10.4
PowerMac G5 Dual 2.3 GHz, 1Gb Ram

Hi,

i get 193ms on a p4 2.8gig with this...

Local a=0,timAkt=0,timAnf=MilliSecs()

While(a<1000000000) 
	a:+1;a:+1;a:+1;a:+1;a:+1;a:+1;a:+1;a:+1
Wend 

timAkt=MilliSecs()-timAnf
Print "From 0 to "+a+" (a Billion) in "+timAkt+" milliseconds." 

The interesting part was to compare this to other tools. Some of them took ages.


Greetings,

taumel

I got:

0 to 1 Billion in 8530 milliseconds

With my iBook G4 1.2GHz

(YAY! First post ever! Bought BlitzMax yesterday)

1492 ms with locals, about ten times slower with globals!

1492 - wasn't that the year that Columbus bumped into the US whilst out looking for the east indies?

Using rod49's code:
0 to 1 Billion in 3606 milliseconds
0 to 1 Billion in 36192 milliseconds(debug)

Using Coorrae's code:

0 to 1 Billion in 2100 milliseconds
0 to 1 Billion in 35404 milliseconds(debug)

Using taumel 's code:

0 to 1 Billion in 794 milliseconds
0 to 1 Billion in 5942 milliseconds(debug)

with athlon xp2500

1446 with Coorraes code

Specs below

I get 2 seconds on Blitzmax and 3 seconds on c++

1737 with Coorraes code

Coorrae's code becomes about 10% faster if you declare a right before the loop. Looking at the assembly, this compiles to add eax,1 instead of add esi,1. I would have expected a :+ 1 to be faster too, but it compiles to the same add eax,1 (instead of inc eax, which I think would be faster).

Strict 

Local start: Int 
Local finish: Int 

Delay 500

start = MilliSecs()

Local a: Int = 0
While (a < 1000000000) 
  a = a + 1 
Wend 

finish = MilliSecs() 

Print "0 to 1 Billion in " + (finish - start) + " milliseconds"  


With Wiering's code, on my Athlon 3000+ under Win XP Pro SP2:

1465 BlitzMax 1.10


With the required, minor adjustments:

2061 Blitz3D 1.90


In both BlitzMax and Blitz3D, it makes no difference using While/Wend or For/Next, or whether the program was run in the IDE or as an Exe (both with no debug).


Curious, I tried my older, Microsoft Basics (code adjusted as needed). With them, there are differences between running in their IDE or as a compiled Exe, as well as using a While/Wend loop or a For/Next one.

I was surprised to see that compiled VB 5 (1997) is slightly faster than Blitz3D (though not as fast as BlitzMax):

In IDE:
67343 Visual Basic 5.0 SP3 (While/Wend)
12343 Visual Basic 5.0 SP3 (For/Next)

Compiled as Exe:
1921 Visual Basic 5.0 SP3 (While/Wend)
1734 Visual Basic 5.0 SP3 (For/Next)


And then there's good ol' QuickBASIC from 1988 <g>:

In IDE:
109296 QuickBASIC 4.5 (While/Wend)
51132 QuickBASIC 4.5 (For/Next)

Stand-alone Exe (no debug):
33007 QuickBASIC 4.5 (While/Wend)
32507 QuickBASIC 4.5 (For/Next)


3037 with duel G4's

On my newly-acquired 933 MHz G4 with OS 10.3.9, I get 3330 with Wiering's code (though I didn't observe moving a's declaration to have any effect either on Mac or PC).