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

Adobe FlashApache Flex

Avatar of undefined
Last Comment
AdrianSmithUK

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
cy_hung

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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);
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23