📜  python时间函数持续时间和内存使用 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:54.284000             🧑  作者: Mango

代码示例1
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