Re: Time in milliseconds
Re: Time in milliseconds
- Subject: Re: Time in milliseconds
- From: Paul Skinner <email@hidden>
- Date: Sat, 31 Jul 2004 08:01:53 -0400
I assume GetMilliSec is returning/reading/calling uptime, but it's too
late to do the math to be sure. Does anyone know the exact mechanism?
example script from the download folder...
set t to GetMilliSec
set hh to t div (3600.0 * 1000.0)
set t to t - hh * (3600.0 * 1000.0)
set mm to t div (60.0 * 1000.0)
set t to t - mm * (60.0 * 1000.0)
set ss to t / 1000.0
hh & ":" & mm & ":" & ss & " since boot" as string
-->23:25:16.154 since boot
Looks like uptime.
On Jul 31, 2004, at 6:07 AM, Dennis W. Manasco wrote:
At 8:42 pm -0400 7/30/04, Paul Skinner wrote:
On Jul 30, 2004, at 5:40 PM, Paul Berkowitz wrote:
On 7/30/04 1:30 PM, "Paul Skinner" <email@hidden> wrote:
GetMilliSec
-->7.3012042E+7
<http://osaxen.com/modules.php?
op=modload&name=Downloads&file=index&req=getit&lid=112>
GetMilliSec is excellent, but it has the same Heisenberg-limitation
that
simply calling an osax adds many milliseconds delay, so it won't in
fact be
accurate.
See my comments below.
set t1 to GetMilliSec
set r to 1000
repeat r times
GetMilliSec
end repeat
set t2 to (GetMilliSec)
(((t2 - t1) / r) as text) & "ms per call"
-->1.166ms per call
-->0.054ms per call
OMM, with repeats between .053 and .059 except for one jump to .064
and one jump to .075.
Interestingly, OMM I get "0.074ms per call" in Script Editor. My
previous post was from Script Debugger. Today I get "0.092ms per call"
from SD consistently (small varance) Perhaps Cron tasks were running
yesterday.
(Dual 1G G4 Spring 2002 OS X 10.2.8 running uncompiled from Script
Editor 1.9.)
Pretty cool.
I assume GetMilliSec is returning/reading/calling uptime, but it's too
late to do the math to be sure. Does anyone know the exact mechanism?
Is there any English documentation? When I open the ReadMe file it
starts OS 9 and displays in Osaka; I think it must be in Japanese
since there are credits at the bottom with .jp mail addresses.
-=-Dennis
Just to nit pick over something that bothered me about the original
code, and should have no real effect on the result, shouldn't the last
line be:
(((t2 - t1) / (r+2)) as text) & "ms per call" ?
The outer two calls are marking the begin and end points of the
timeframe. The first call sets the start time, a loop runs, then a
call sets the end time. Only the second call occurs inside the timed
window. To remove that call It should have been...
(((t2 - t1) / (r+1)) as text) & "ms per call"
This would only be correct timing code for timing the timing code. Ok,
that sounds weird. If you were timing a call to ascii number you would
not be able to make this correction. It only is appropriate here
because the call you are timing is the same call making the timing.
I used the standard code that I use to time ordinary calls. When
timing non-getmillisec and/or non-chrono calls to be accurate I think
you'd have to time the timing call and remove the average time of one
timing call from whatever you are timing.
Whew!
As for accuracy of any timings of any code, I think that the 66
processes running (with just mail, SD and SE apps open) play a role.
paragraph 1 of (do shell script "top -l1")
-->"Processes: 66 total, 2 running, 64 sleeping... 207 threads
08:00:02"
(Though, for r = 1000, /r gives a much nicer looking result than
/(r+2)...)
(Just for the heck of it)
set bigRes to 0
set bigLoop to 1000
repeat bigLoop times
set r to 1000
set t1 to GetMilliSec
repeat r times
GetMilliSec
end repeat
set t2 to (GetMilliSec)
set bigRes to (bigRes + ((t2 - t1) / (r + 2)))
end repeat
((bigRes / bigLoop) as text) & " ms per call"
--> 0.056177644711 ms per call
and that's with the little radioactive beach ball spinning...
Even more telling...
set t1 to GetMilliSec
set t2 to GetMilliSec
set t3 to GetMilliSec
set t4 to GetMilliSec
set t5 to GetMilliSec
set t6 to GetMilliSec
set t7 to GetMilliSec
set t8 to GetMilliSec
set t9 to GetMilliSec
set t10 to GetMilliSec
set t11 to GetMilliSec
set t12 to GetMilliSec
set t13 to GetMilliSec
set t14 to GetMilliSec
set t15 to GetMilliSec
set t16 to GetMilliSec
set t17 to GetMilliSec
set t18 to GetMilliSec
set t19 to GetMilliSec
set t20 to GetMilliSec
set t21 to GetMilliSec
set t22 to GetMilliSec
set t23 to GetMilliSec
set t24 to GetMilliSec
set t25 to GetMilliSec
set t26 to GetMilliSec
set t27 to GetMilliSec
set t28 to GetMilliSec
set t29 to GetMilliSec
set t30 to GetMilliSec
set AppleScript's text item delimiters to return
{t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16,
t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30}
as text
-->
"8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375204E+7
8.6375205E+7
8.6375205E+7
8.6375205E+7
8.6375205E+7
8.6375205E+7
8.6375205E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375206E+7
8.6375207E+7"
While replacing these calls with 'chrono' and running in smile returns
"78.064832000004
2.160000003641E-4
1.780000020517E-4
2.240000030724E-4
1.869999978226E-4
1.749999937601E-4
1.710000069579E-4
1.699999993434E-4
1.70999992406E-4
1.970000012079E-4
1.740000006976E-4
1.710000069579E-4
1.699999993434E-4
0.004195000001
4.439999902388E-4
2.050000039162E-4
1.809999957914E-4
7.360000017798E-4
1.900000061141E-4
1.760000013746E-4
1.720000000205E-4
1.720000000205E-4
1.70999992406E-4
1.710000069579E-4
1.699999993434E-4
1.70999992406E-4
1.699999993434E-4
1.840000040829E-4
1.73000007635E-4
1.720000000205E-4"
hmmm.... gonna make coffee and mull that over.
Paul
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.