toLocaleUpperCase と toUpperCase って速度違ったりする?

by yasurageruheya
違わないみたい
♥0 | Line 59 | Modified 2011-11-27 09:49:33 | MIT License
play

ActionScript3 source code

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

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.utils.getTimer;
	public class FlashTest extends Sprite {
		private const LOW:String = "abcdefghijklmnopqrstuwxyz";
		private const UP:String = "ABCDEFGHIJKLMNOPQRSTUWXYZ";
		
		private const COUNT:uint = 100000;
		
		private const txt:TextField = new TextField();
		
		public function FlashTest() {
			// write as3 code here..
			
			txt.autoSize = "left";
			
			if (stage) init(null);
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			addChild(txt);
			
			stage.addEventListener(MouseEvent.CLICK, test);
			test(null);
		}
		
		private function test(e:MouseEvent):void 
		{
			var i:int = COUNT;
			var str:String;
			txt.text = "";
			var timer:int = getTimer();
			while (i--)
			{
				str = LOW.toUpperCase();
			}
			txt.appendText("LOW.toUpperCase() : " + (getTimer() - timer) + "ms\n");
			
			i = COUNT;
			timer = getTimer();
			while (i--)
			{
				str = LOW.toLocaleUpperCase();
			}
			txt.appendText("LOW.toLocaleUpperCase() : " + (getTimer() - timer) + "ms\n");
			
			i = COUNT;
			timer = getTimer();
			while (i--)
			{
				str = UP.toLowerCase();
			}
			txt.appendText("UP.toLowerCase() : " + (getTimer() - timer) + "ms\n");
			
			i = COUNT;
			timer = getTimer();
			while (i--)
			{
				str = UP.toLocaleLowerCase();
			}
			txt.appendText("UP.toLocaleLowerCase() : " + (getTimer() - timer) + "ms\n");
			
			txt.appendText("クリックで再計算");
		}
	}
}