Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Created October 2, 2012 18:48
Show Gist options
  • Save IQAndreas/3822331 to your computer and use it in GitHub Desktop.
Save IQAndreas/3822331 to your computer and use it in GitHub Desktop.
Test AS3 variable definition placement performance
private function testDefenitionPlacementPerformance(n:uint):void
{
var startTime:uint;
startTime = getTimer();
var outside:Number;
for (var i:int = 0; i < n; i++)
{
outside = Math.random();
}
trace("Defined outside:", getTimer() - startTime, "ms");
startTime = getTimer();
for (var j:int = 0; j < n; j++)
{
var inside:Number = Math.random();
}
trace("Defined inside:", getTimer() - startTime, "ms");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment