performance - ActionScript - Profile Speed Of Script From Code? -


i'm trying cave-man-profile speed of code code using date class , trace statements. it's not working out well.

package {    import flash.display.sprite;  public class test extends sprite     {     public function test()         {         var now:date = new date();         var profilespeedmark:number = now.getmilliseconds();          var myarray:array = new array();         (var i:number = 0; < 1000000; i++)             myarray.push(math.random());          var profilespeedresult:number = now.getmilliseconds() - profilespeedmark;         trace(profilespeedresult);         }     } } 

the idea here able compare different ways of coding functions , determine 1 faster. unless i'm on super slow computer i'm not sure if possible, short functions.

the problem way you've done things in example code date class has fixed value -- you're comparing time before tests time before tests again. try instantiating date object after tests , taking time that:

var before:date = new date(); test(); var after:date = new date(); var timetaken:number = after.time - before.time; 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -