Created
January 29, 2010 11:07
-
-
Save whitered/289652 to your computer and use it in GitHub Desktop.
simple performance test template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.text.TextField; | |
[SWF(width="800",height="600",frameRate="120",backgroundColor="#ffffff")] | |
public class PerformanceTest extends Sprite | |
{ | |
private static const LIMIT:int = 10000; | |
private var tf:TextField; | |
public function PerformanceTest() | |
{ | |
tf = new TextField(); | |
tf.width = stage.stageWidth; | |
tf.height = stage.stageHeight; | |
addChild(tf); | |
addEventListener(Event.ENTER_FRAME, handleEnterFrame); | |
} | |
private function handleEnterFrame(event:Event):void | |
{ | |
var i:int; | |
const t1:uint = new Date().getTime(); | |
for (i = 0;i < LIMIT;i++) | |
{ | |
// execute action 1 | |
} | |
const t2:uint = new Date().getTime(); | |
for (i = 0;i < LIMIT;i++) | |
{ | |
// execute action 2 | |
} | |
const t3:uint = new Date().getTime(); | |
trace(t2 - t1, ":", t3 - t2); | |
tf.appendText((t2 - t1) + " : " + (t3 - t2) + "\n"); | |
if(tf.textHeight > tf.height) removeEventListener(Event.ENTER_FRAME, handleEnterFrame); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment