标签:cloc 系统 进程 imp 例子 调用 一段 pre 使用
在统计python代码 执行速度时要使用到time包,在查找相关函数时有time.time()
和time.clock()
两个函数可供选择。而两者是有区别的:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
import time
start1 = time.clock()
start2 = time.time()
for i in range(10000):
print (i)
end1 = time.clock()
end2 = time.time()
print ('wall time is different is %6.3f' % (end1 - start1))
print ('CPU time is different is %6.3f' % (end2 - start2))
wall time is different is 3.593
CPU time is different is 3.594
time模块的两个函数time.clock()和time.time()的区别
标签:cloc 系统 进程 imp 例子 调用 一段 pre 使用
原文地址:https://www.cnblogs.com/lovely-bones/p/11670984.html