Speed in FMX04 and Strict Typing

heh, well, I was really bored, so I decided to run a few tests on the differences in speed in FMX04 between a strictly typed variable and a non-strictly typed variable… the differences were amazing.

I used these two pieces of code:


for(var num:Number = 0;num<50000;num++){
	56+51;
	21+23;
	53+21;
	if(num == 4999){
		var totalTimeDefined = getTimer();
	}
}
for(var num2 = 0;num2<50000;num2++){
	56+51;
	21+23;
	53+21;
	if(num2== 4999){
		var totalTimeNotDefined = getTimer();
	}
}
trace(totalTimeDefined);
trace(totalTimeNotDefined-totalTimeDefined);

The output varied between 200 and 170 and 900 to 1100 on my P3 700. I’m sure the difference would get bigger and bigger as the iterations got bigger, but don’t quote me on that.

I just thought some of you might find this interesting.

The moral of the story is: always use strictly typed variables when you can in 04 :slight_smile: