[MacRuby-devel] MacRuby scripting bridge speed

Stephen Horne fatste at gmail.com
Fri Dec 23 04:17:56 PST 2011


Hi Josh.
> Joshua Ballanco <mailto:jballanc at gmail.com>
> 22 December 2011 15:04
> On Friday, December 16, 2011 at 10:17 AM, Stephen Horne wrote:
>
> I am afraid I don't have a copy of InDesign, so I cannot test your 
> specific situation. However, it would be interesting to know what part 
> of your script is slow. Specifically, I would be interested in seeing 
> some benchmarking to indicate whether your script is wasting more time 
> on the "load_bridge_support_file" line or the 
> "SBApplication.applicationWithURL" line. (I suppose calls through to 
> InDesign could be the bottle neck as well, but that would be rather 
> unexpected I should think.)
>
> You can probably start off with Ruby's Benchmark library (with some 
> decent documentation here: 
> http://rubydoc.info/stdlib/benchmark/frames , though honestly you only 
> really need "Benchmark.measure"). From there it might be interesting 
> to look at other profiling results, but best to start simple.

I've had a look at benchmark, and it seems it is the bit that creates 
the link to InDesign that's the bottleneck.

Here's the code I used:

     #!/usr/local/bin/macruby
     framework 'ScriptingBridge'
     require 'benchmark'

     Benchmark.bm(7) do |x|
       x.report("load_BSF:    ") {
         load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'}

       x.report("Create NSURL:") {
         @appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign 
CS5/Adobe InDesign CS5.app")}

       x.report("Link to ID:  ") {
         @id = SBApplication.applicationWithURL(@appurl)}

       x.report("Link to doc1:") {
         @doc = @id.activeDocument}
     end

and here's the report it returned:

                       user     system      total        real
     load_BSF:      0.130000   0.000000   0.130000 (  0.109424)
     Create NSURL:  0.000000   0.000000   0.000000 (  0.001404)
     Link to ID:   27.770000   1.270000  29.040000 ( 14.824474)
     Link to doc1:  0.000000   0.000000   0.000000 (  0.000127)


Fb
>
> - Josh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20111223/cfd47978/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1000 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20111223/cfd47978/attachment.jpg>


More information about the MacRuby-devel mailing list