Answers for "python time function duration and memory usage"

0

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
Posted by: Guest on May-06-2021

Code answers related to "python time function duration and memory usage"

Python Answers by Framework

Browse Popular Code Answers by Language