Re: FYI
Re: FYI
- Subject: Re: FYI
- From: Shane Stanley <email@hidden>
- Date: Sat, 10 Sep 2016 14:22:07 +1000
On 10 Sep 2016, at 1:51 PM, Christopher Stone <email@hidden> wrote:
There's a lot of latency in a do shell script call, so that doesn't offer you much precision.
It's probably accurate to one decimal place. Running this:
set x to (do shell script "perl -e 'use Time::HiRes qw(time); print time'") as real set y to (do shell script "perl -e 'use Time::HiRes qw(time); print time'") as real y - x
I get ~0.03 seconds. Worse, running it repeatedly shows that any other numbers returned might as well be random. You wouldn't get much worse values using this:
set theStr to "1/1/1970" set x to (current date) - (date theStr) + (random number from 0.0 to 0.999) - (random number from 0.0 to 0.999)
Running this:
use framework "Foundation" set x to current application's NSDate's timeIntervalSinceReferenceDate() set y to current application's NSDate's timeIntervalSinceReferenceDate() y - x
I get ~1.0E-4, or about 0.0001. Importantly, running it repeatedly shows results that would almost always round to 0.0001, and certainly to a consistent three decimal places. As NSDate is only documented to deliver millisecond or better accuracy, that's probably as good as you will get using AppleScript.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
- Follow-Ups:
- Re: FYI
- From: Brian Christmas <email@hidden>
References: | |
| >FYI (From: Brian Christmas <email@hidden>) |
| >Re: FYI (From: Christopher Stone <email@hidden>) |