I just threw together a really straightforward stopwatch class, for use when profiling operations in ActionScript code. You can either use it in an old-skool procedural way:
var tt:TickTock = new TickTock();
tt.start();
doSomeWork();
tt.stop();
trace( "That took "+tickTock.elapsedTimeInMilliseconds+" millisconds" );
or in a fancy-pants, functional, closure-y way:
var tt:TickTock = TickTock.measure( function(){
doSomeWork();
});
trace( "That took "+tickTock.elapsedTimeInMilliseconds+" millisconds" );
Being primarily a ruby guy, I prefer the fancy-pants approach ;)
The class, along with a little sample app, is
up on GitHub now.
No comments:
Post a Comment