• 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: JSA -- now I believe this is a bug (JSA or AS)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSA -- now I believe this is a bug (JSA or AS)


  • Subject: Re: JSA -- now I believe this is a bug (JSA or AS)
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 18 Dec 2014 22:09:49 +1100

On 18 Dec 2014, at 8:09 pm, Emmanuel LEVY <email@hidden> wrote:

Indeed, JS in incredibly fast compared to AS, look:

----
callJavaScript ww script "var i, x=0 ; for ( i = 0 ; i < 1000000 ; i++ ) x += Math.tan ( 1 ) ; x" [1]
----
runs in 0.08 second! Or, 0.08 microsecond per iteration. (The final "x" is to make sure some optimization process is not skipping the whole computation, considering no-one needs the result!) This is on a 2Ghz clocked machine.

You need a faster Mac:

use scripting additions
use framework "Foundation"
use framework "WebKit"
set theDate to current application's NSDate's |date|()
set theWebView to current application's WebView's alloc()'s init()
set x to (theWebView's stringByEvaluatingJavaScriptFromString:"var i, x=0 ; for ( i = 0 ; i < 1000000 ; i++ ) x += Math.tan ( 1 ) ; x") as text
current application's NSDate's |date|()'s timeIntervalSinceDate:theDate

~0.06 seconds. (And before anyone tries this at home, you need to run it in the foreground.)


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

 _______________________________________________
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: 
 >JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Shane Stanley <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Shane Stanley <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Shane Stanley <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Deivy Petrescu <email@hidden>)
 >Re: JSA -- now I believe this is a bug (JSA or AS) (From: Emmanuel LEVY <email@hidden>)

  • Prev by Date: Re: odd Numbers's behaviour
  • Next by Date: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Previous by thread: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Next by thread: Re: JSA -- now I believe this is a bug (JSA or AS)
  • Index(es):
    • Date
    • Thread