AnsweredAssumed Answered

What is your "import arcpy" overhead?

Question asked by Matt.Wilkie.Yukon on Mar 5, 2020
Latest reply on Mar 10, 2020 by RTM2@cityofhenderson.com_HendersonNV

I'm curious, how long does it take in your machine(s) for your scripts to get ready to start working?

Put something like this at the beginning of some scripts and share the results.

 

from timeit import default_timer as timer
start = timer()
from datetime import datetime, timedelta
print('=== {}'.format(datetime.now()))

start_arc = timer()
import arcpy
done_arc = timer() - start_arc

print('--- import arcpy overhead: {}'.format(timedelta(seconds=done_arc)))

#import os, math, ...
#carry on with your stuff

elapsed_time = timedelta(seconds=timer() - start)
    # get timer seconds and convert to hh:mm:ss
print('=== Total Elapsed Time: {}'.format(elapsed_time))

 

After about a week and perhaps 30 trials in various circumstances the fastest time I've ever seen is 7.8 seconds, the slowest is 10.5, and the median is ~8.5.

 

(updated code to run in py 2.7 and 3.6+)

Outcomes