Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python time function duration and memory usage

import time
import resource 

time_start = time.perf_counter()
# insert code here ...
time_elapsed = (time.perf_counter() - time_start)
memMb=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024.0/1024.0
print ("%5.1f secs %5.1f MByte" % (time_elapsed,memMb))

# sample output:
# 2.3 secs 140.8 MByte
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #time #function #duration #memory #usage
ADD COMMENT
Topic
Name
5+6 =