[AS3 SNIPPET] Quick benchmark a function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | function benchmark(func:Function):void { var startTime:Date = new Date(); func(); var endTime:Date = new Date(); var benchmark:Number = endTime.time - startTime.time; var result:String = benchmark + "ms"; trace("result: " + result); } function test():void { var counter:int = 100000000; while (counter > 0) { counter--; } } benchmark(test); |
Thanks, I was about to write my own but then I found yours right away and you saved me about 1 minute.
Thanks for the code.