Comparison of counter variable's data type in for loop

by Fumio
Comparing the data types of counter variables in for statements.

forステートメントにおけるカウンタ変数のデータ型による処理速度を比較します。
♥0 | Line 55 | Modified 2010-12-20 23:44:54 | MIT License
play

ActionScript3 source code

/**
 * Copyright Fumio ( http://wonderfl.net/user/Fumio )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/uhX4
 */

package {
	import flash.display.Sprite;
	import flash.utils.getTimer;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flashx.textLayout.formats.TextAlign;
	[SWF(width = "240",height = "180")]
	public class TypingCounterVariable extends Sprite {
		private const AMOUNT:uint = 100000000;
		private var started:uint;
		private var my_txt:TextField = new TextField();
		private var label_txt:TextField = new TextField();
		private var my_fmt:TextFormat = new TextFormat();
		public function TypingCounterVariable() {
			// Creating a TextField for display
			createTextField();
			// Starting test
			testing_uint();
			testing_int();
			testing_Number();
			testing_untyped();
		}
		private function testing_uint():void {
			started = getTimer();
			for (var i:uint = 0; i < AMOUNT; i++) {}
			xTrace(getTimer() - started);
		}
		private function testing_int():void {
			started = getTimer();
			for (var i:int = 0; i < AMOUNT; i++) {}
			xTrace(getTimer() - started);
		}
		private function testing_Number():void {
			started = getTimer();
			for (var i:Number = 0; i < AMOUNT; i++) {}
			xTrace(getTimer() - started);
		}
		private function testing_untyped():void {
			started = getTimer();
			for (var i = 0; i < AMOUNT; i++) {}
			xTrace(getTimer() - started);
		}
		private function createTextField():void {
			addChild(my_txt);
			addChild(label_txt);
			// my_txt.x +=  70;
			my_txt.autoSize = TextFieldAutoSize.RIGHT;
			my_fmt.align = TextAlign.RIGHT;
			my_txt.defaultTextFormat = my_fmt;
			label_txt.autoSize = TextFieldAutoSize.LEFT;
			label_txt.text = "uint:\nint:\nNumber:\nuntyped:";
		}
		private function xTrace(n:int):void {
			my_txt.appendText(String(n) + "\n");
		}
	}
}