What is your "import arcpy" overhead?

1563
17
03-05-2020 12:02 PM
MattWilkie1
Occasional Contributor II

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+)

Tags (2)
17 Replies
BlakeTerhune
MVP Regular Contributor

On Windows 10 with ArcGIS 10.5.1, run from VS Code

--- import arcpy overhead: 0:00:02.766314
=== Total Elapsed Time: 0:00:02.768425‍‍
0 Kudos
MattWilkie1
Occasional Contributor II

Oh wow, I want times like that. It's so annoying to wait 10 secs for startup and then have the real work happen in half that time. I wonder why mine is so much slower. What's your machine and how are you licensed (AGOL Named User, Concurrent, Single Use, Portal, ...)?

My machine:

Dell Precision Tower 7810
2 physical processors: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz, 2401 Mhz, 6 Core(s), 12 Logical Processor(s)

32 GB Ram

Win10 Enterprise x64, version 10.0.18362 Build 18362

C: and 😧 are Samsung SSD 840 EVO 500GB (SSD).

Licensing:

Pro: AGOL Named User

ArcMap: Concurrent license manager (in same building).

Pro's python 3.6 via Pyzo IDE:

--- import arcpy overhead: 0:00:09.052498

ArcMap's python 2.7 via Pyzo IDE:

--- import arcpy overhead: 0:00:06.414285

(I updated the code in first post so it will run in python 2.7 also)

0 Kudos
DanPatterson_Retired
MVP Emeritus

is everyone in a rush today  

or is esri's "call home" slow today?

https://community.esri.com/thread/249381-strip-arcpy-libraries 

BenTurrell
Occasional Contributor III

Hey Matt Wilkie‌,

My results are:

=== 2020-03-06 09:54:51.555443
--- import arcpy overhead: 0:00:05.055231
=== Total Elapsed Time: 0:00:05.098868

Thanks,

Ben


If this answer has helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

JoshuaBixby
MVP Esteemed Contributor

On my local PC, ArcGIS Desktop 10.8 runs around 4 seconds while ArcGIS Pro 2.5 takes 14 seconds.  The difference in times on my machine is easily explained by licensing mode/model.  For ArcGIS Desktop 10.8 I am using Single-Use (which will be the fastest of any licensing model) while for Pro 2.5 I am using Named User licensing from AGOL.  I am quite sure that Single Use licensing for Pro would put it down around 6 seconds or faster.

If you care about ArcPy startup times, it starts with sharing what your current licensing model is.

ShaneMiles
Esri Contributor

Hi Matt Wilkie‌, 

My results were:

=== 2020-03-06 15:15:35.488000
--- import arcpy overhead: 0:00:03.081489
=== Total Elapsed Time: 0:00:03.094335

Shane
JoeBorgione
MVP Emeritus

I surprised to see:

=== 2020-03-06 15:20:12.398747
--- import arcpy overhead: 0:00:02.838384
=== Total Elapsed Time: 0:00:02.838892

It always seems much longer that that.

(arcgis Pro 2.5, advanced license as named user in agol...)

That should just about do it....
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You either had Pro open or was working with Pro earlier in the day.  If you reboot and do a cold test, i.e., without having open Pro, I am guessing it will be noticeably longer.

0 Kudos
JoeBorgione
MVP Emeritus

after a machine restart:

=== 2020-03-06 15:30:26.956646
--- import arcpy overhead: 0:00:03.617659
=== Total Elapsed Time: 0:00:03.618505

which is still faster than I would have bet on.  It always seems longer than that. Just restarted spyder and got:

=== 2020-03-06 15:33:50.404610
--- import arcpy overhead: 0:00:03.998263
=== Total Elapsed Time: 0:00:03.998689

interesting.....

That should just about do it....
0 Kudos