python -mtimeit in windows

来源:互联网 发布:局域网桌面直播软件 编辑:程序博客网 时间:2024/05/22 14:56

$ python -mtimeit -s"from math import sqrt; x = 123" "x**.5" 
1000000 loops, best of 3: 0.445 usec per loop 
 
$ python
-mtimeit -s"from math import sqrt; x = 123" "sqrt(x)" 
1000000 loops, best of 3: 0.574 usec per loop 
 
$ python
-mtimeit -s"import math; x = 123" "math.sqrt(x)" 
1000000 loops, best of 3: 0.727 usec per loop 

 

from http://stackoverflow.com/questions/842245/which-is-more-accurate-x-5-or-math-sqrtx