• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: FYI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FYI


  • Subject: Re: FYI
  • From: Brian Christmas <email@hidden>
  • Date: Sat, 10 Sep 2016 16:10:20 +1000

Thank you to Chris, and particularly Shane.

Even though what I wanted precision time for was just to accurately time each dwell of my App that just tests Safari on my freezing iMac, I’d never timed precisely before, and being a stickler for accuracy, wanted to find out how, just for my own safisfaction.

Hopefully others might now benefit from Shanes insight.

Of note, my iMac froze again several nights ago, even after running DetectX.app. I’ve now installed Sierra GM, and am again testing, to see if it freezes too.

Regards

Santa


On 10 Sep. 2016, at 2:22 pm, Shane Stanley <email@hidden> wrote:

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.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

And what, you ask, was the beginning of it all?
And it is this......
Existence that multiplied itself
For sheer delight of being
And plunged with numberless trillions of forms
So that it might
find
itself
innumerably

Sri Aurobindo



 _______________________________________________
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

References: 
 >FYI (From: Brian Christmas <email@hidden>)
 >Re: FYI (From: Christopher Stone <email@hidden>)
 >Re: FYI (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 13, Issue 374
  • Next by Date: Ongoing problem with Bill Cheesemans Accessibilty code snippet.
  • Previous by thread: Re: FYI
  • Next by thread: Safari 10.0 bug?
  • Index(es):
    • Date
    • Thread