Simple Arcpy clock/timer

3687
4
05-30-2014 06:38 AM
AndrewTuleya2
New Contributor II
Does anyone have simple syntax so I can add a timer or clock to my Arcpy script?

Thanks.
Tags (2)
4 Replies
BenSciance
New Contributor II
import time


Check this link out.

or this one
0 Kudos
markdenil
Occasional Contributor III
import datetime
start = datetime.datetime.now()
print 'start run: %s\n' % (start)
### do groovy stuff here
print 'finished run: %s\n\n' % (datetime.datetime.now() - start)
ChrisSnyder
Regular Contributor III
What I do:

import time
time1 = time.clock()
#do stuff
time2 = time.clock()
print "Stuff took " + str(time2-time1) + " seconds"
JamesCrandall
MVP Frequent Contributor
class Timer:    
    def __enter__(self):
        self.start = time.clock()
        return self

    def __exit__(self, *args):
        self.end = time.clock()
        self.interval = self.end - self.start


import arcpy

t = Timer()
with t:
   #list the things in the workspace
   ws_output = r'in_memory'
   for fc in arcpy.ListFeatureClasses():
        print fc

itemsecs = "Total processing seconds: %.02f secs." % (t.interval)
print itemsecs