Skip to content

Instantly share code, notes, and snippets.

@hhatto
Created February 25, 2015 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhatto/a959428f8e8f59672bc2 to your computer and use it in GitHub Desktop.
Save hhatto/a959428f8e8f59672bc2 to your computer and use it in GitHub Desktop.
python pow bench
===== =====
(slow) 0.481754[sec]
math.pow(13 * 0.3, 2)
math.pow(2 * 1, 0.5)
math.pow(0.2 * 0.2, 0.5)
(fast) 0.026431[sec]
(13 * 0.3) ** 2
(2 * 1) ** 0.5
(0.2 * 0.2) ** 0.5
18.23 times faster
===== =====
(slow) 0.453407[sec]
pow(13 * 0.3, 2)
pow(2 * 1, 0.5)
pow(0.2 * 0.2, 0.5)
(fast) 0.026522[sec]
(13 * 0.3) ** 2
(2 * 1) ** 0.5
(0.2 * 0.2) ** 0.5
17.10 times faster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment