python模仿matlab的tic/toc计时,tictoc,[Python]代码im


[Python]代码

import timedef tic():    globals()['tt'] = time.clock()def toc():    print '\nElapsed time: %.8f seconds\n' % (time.clock()-globals()['tt'])

使用示例

from mytictoc import tic, toctic()for i in range(100000):    passtoc()

运行结果

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32Type "copyright", "credits" or "license()" for more information.>>> ================================ RESTART ================================>>> Elapsed time: 0.01879716 seconds>>> 

评论关闭