I’ve noticed that my scripts run considerably slower when I run them as applications from the Finder. Some of my scripts run several times faster in the script editor than as stand-alones.
For example, the following code, which creates a table in word and fills it in with values from a list of lists, takes 13 seconds on my machine to execute in the Script Editor, but 32 seconds when run as a stand-alone app:
set num_rows to count the_rows
set num_columns to count (item 1 of the_rows)
--Enter the_rows into a table
tell application "Microsoft Word"
set new_doc to make new document
set orientation of page setup of new_doc to orient landscape
set the_table to make new table at new_doc with properties {text object:(create range new_doc start 0 end 0), number of rows:num_rows, number of columns:num_columns}
activate
repeat with i from 1 to num_rows
repeat with j from 1 to num_columns
set cell_txt to (item j of (item i of the_rows)) as text
set content of text object of (get cell from table table 1 of new_doc row i column j) to cell_txt
end repeat
end repeat
end tell
the_rows is a list of lists with 20 rows and 5 columns, and a total of 2165 words.
The difference in performance is even more marked with Script Debugger 4.0. The same script takes 2 seconds to run in its editor, but 32 seconds to run when running as an app from the Finder.
Does anyone know why there is this huge difference in speeds between the editor and the finished product? It would be great if there were a way to make the final app run at a speed closer to how it runs in the editor.
Thanks in advance,
Greg
Model: Intel Mac Pro - 2GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)