import time start =time.clock() #中间写上代码块 def test(): a = 1 b = 2 c =a + b if c != 3: print(c) return else: print(c) return i = 0 for i in range(1000000): test() end = time.clock() print('Running time: %s Seconds'%(end-start))