Link to home
Start Free TrialLog in
Avatar of AdrianSmithUK
AdrianSmithUK

asked on

Flash Timer Code: How to measure code execution time.

I'm using flash remoting and I need a script to measure the code execution time.

I tried using the script below but sometimes the result is negative. (eg -841ms)

Does anybody have a robust code execution timer function?


var t1:Date = new Date();

//Do something

var t2:Date = new Date();
trace(t2.getMilliseconds() - t1.getMilliseconds());

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of cy_hung
cy_hung
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AdrianSmithUK
AdrianSmithUK

ASKER

Many thanks:

Final solution:

import flash.utils.getTimer;
var t1:uint = getTimer();
//Do something
var t2:uint = getTimer();
var delay:uint= t2 - t1;
trace(delay);