python -mtimeit in windows

$ 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章