• 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: Script Speed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script Speed


  • Subject: Re: Script Speed
  • From: Alex Zavatone <email@hidden>
  • Date: Fri, 09 Nov 2012 17:38:41 -0500


On Nov 9, 2012, at 4:55 PM, Thomas Fischer wrote:

Hello Alex,

for timing scripts I prefer Tetsuro Kurita's LapTime.osax (http://www.script-factory.net/software/OSAX/LapTime/en/index.html).
This seems to be somewhat more economical than starting a Perl engine.

Best
Thomas

Thank you Thomas.  Glad to know this exists.   Even though you are 100% correct, if you run my script using delay and sleep times of 0, the whole script executes in less than one millisecond, so the overhead might not be as bad as expected.

FYI, the test system is a 10.6.8, 17" 2.3 GMz i7 MBP with 16 GB of RAM.

(*Delay 0 - 0.0*)
(*shell sleep 0 - 0.0*)

-- 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.
-- http://macgrunt.com/2011/10/13/timing-applescripts/#comment-821
-- 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 0 -- horrible command.  Use the shell sleep command instead.
logOperation("Delay 0")


do shell script "sleep 0"
logOperation("Shell sleep 0")
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

 _______________________________________________
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: 
 >Script Speed (From: Paul Abney <email@hidden>)
 >Re: Script Speed (From: Alex Zavatone <email@hidden>)
 >Re: Script Speed (From: Thomas Fischer <email@hidden>)

  • Prev by Date: Re: Script Speed
  • Next by Date: Mail script for grouping messages?
  • Previous by thread: Re: Script Speed
  • Next by thread: Re: Script Speed
  • Index(es):
    • Date
    • Thread