- 得到代码执行时间脚本:
-
- import time
- t0 = time.time() # start time
- # the code to time goes here
- t1 = time.time() # end time
- print(t1 - t0)
-
-
- if __name__ == '__main__':
- import time
- t0 = time.time()
- result = slow()
- t1 = time.time()
- print("slow(): %f" % (t1 - t0))
- t0 = time.time()
- result = pythonic()
- t1 = time.time()
- print("pythonic(): %f" % (t1 - t0))
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/91975/viewspace-2142326/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/91975/viewspace-2142326/