int and uint
forked from var, const, static (diff: 131)
ActionScript3 source code
/**
* Copyright bkzen ( http://wonderfl.net/user/bkzen )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cjZs
*/
// forked from bkzen's var, const, static
package {
import flash.system.Capabilities;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.utils.getTimer;
import com.actionscriptbible.Example;
public class Test extends Example {
private function onClick(e:Event):void
{
var i: int, n: int = 10000000, m: uint, t: int;
if (!isDebug) n *= 5;
t = getTimer();
for (i = 0; i < n; i++)
{
m = 2147483647 >>> (32 - 1);
}
trace("int max : ", getTimer() - t);
t = getTimer();
for (i = 0; i < n; i++)
{
m = 2147483648 >>> (32 - 1);
}
trace("int max + 1 : ", getTimer() - t);
t = getTimer();
for (i = 0; i < n; i++)
{
m = testA >>> (32 - 1);
}
trace("int max (const) : ", getTimer() - t);
t = getTimer();
for (i = 0; i < n; i++)
{
m = testB >>> (32 - 1);
}
trace("int max + 1 (const) : ", getTimer() - t);
trace("---");
}
public const testA: int = 2147483647;// int max
public const testB: uint = 2147483648;// int max + 1
private var isDebug: Boolean;
public function Test() {
stage.addEventListener(MouseEvent.CLICK, onClick);
trace("click stage : " + Capabilities.version, (isDebug = Capabilities.isDebugger) ? "debug player" : "");
}
}
}