If you're running it through SD, have you turned debugging off?
Are you running it as a compiled app?
If so, are you using the delay command at all?
Whenever this happens, the first thing I do is turn a timer property on and then whenever an operation is complete, I issue a logOperation like so:
on logOperation(operationName) set elapsedTime to (the (time of the (current date)) - pStartTime) as string log operationName & " - " & elapsedTime end
This requires that you declare a property called pStartTime at the start of your script like so:
property pStartTime : the time of the (current date)
BUT, that doesn't give you millisecond granularity. Thankfully, someone already solved this but he (me) forgot all about it until trying to give you an answer.
Thanks to MacGrunt.com where my previous solution that I completely forgot about was saved for posterity.
In any case, here's an elapsed time script that is accurate down to the millisecond that I just made for you.
Just call InitTimer() and then whenever you issue a command and want to see how long it took from the start, call logOperation("the thing that I did") as shown in the run handler. If you want to track the time it takes between operations, just call initTimer() again right after you call logOperation.
Cheers.
-- script elapsedTime
-- Alex Zavatone 11092012 -- thanks to macgrunt.com who actually remembered that I solved this once before and put up a web page about it since I -- forgot all about it. -- This is what happens when your mother has a habit of dropping you on your head on a regular basis.
property pStartTime : 0
on run initTimer() delay 1 -- horrible command. Use the shell sleep command instead. logOperation("Delay 1")
do shell script "sleep 1" logOperation("shell sleep 1") end run
on initTimer() set pStartTime to getMS() end initTimer
on logOperation(operationName) set elapsedTime to getMS() - pStartTime log (operationName & " - " & elapsedTime) end logOperation
on getMS() set msRightNowScript to "perl -e 'use Time::HiRes qw(time); print time'" set msTime to ((do shell script msRightNowScript) as integer) * 1000
return msTime end getMS -- end script
|