Select to view content in your preferred language

Python Script Tool Startup Performance

685
4
05-06-2014 05:55 AM
MattNicol
Regular Contributor
I created a series of Python script tools that run in ArcMap 10.2 and noticed that there was significant lag before any code I wrote ran.

As a test, I created a Python script file with no executable code in it.  I didn't even import arcpy.  Under these conditions, the tool still takes around 25 seconds to run.

I tried enabling/disabling background processing and logging, and neither of these had a noticeable effect.

Does anyone have any suggestions for how to improve script tool startup speed?
Tags (2)
0 Kudos
4 Replies
ChrisSnyder
Honored Contributor
Some things to try:

  1. Make sure the .tbx and script files are accessible via a fast network connection or better yet on your local machine

  2. Delete the geoprocessing history. Believe me, this can build up to a surprisingly large amount of file space. These .xml files are stored in: C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcToolbox\History

  3. This may be the most effective but be aware all your ArcMap/ArcCatalog settings (toolbars, paths, settings, etc) will go away... Try renaming (or deleting) your normal.mxt and normal.gxt files... These are the template files that control the customizations to ArcMap/Catalog. I make a habit of deleting these every so often when start up performance (ArcMap, ArcCatalog, import arcpy, etc.)goes down. Try just renaming these (they will get auto-recreated) and you will have your back ups in case you need to go back to the originals. These files are located at: C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcMap\Templates and C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog

0 Kudos
MattNicol
Regular Contributor
Thank you for the suggestions!  Unfortunately, they did not have an effect on performance in this case, but they all look like great suggestions for managing performance in general.
0 Kudos
curtvprice
MVP Esteemed Contributor
Do you have the checkbox set from the script property second tab: "Run Python script in process" - this allows your script to spawn off ArcMap's existing python process - saving startup time.
0 Kudos
MattNicol
Regular Contributor
Curtis, thank you for the idea!  My scripts were all running in-process.

Surprisingly, in my empty script tool case, the tool finished in around 12 seconds when I ran it out-of-process.  When I tried this with my real script, I encountered an error though.  From the page below, it looks like Esri only recommends running scripts out-of-process in special cases:

http://resources.arcgis.com/en/help/main/10.1/index.html#//00150000000r000000
0 Kudos