Last active
December 15, 2015 15:05
-
-
Save cloneko/6ea401fdb2260e4b4359 to your computer and use it in GitHub Desktop.
3.141592
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from benchmarker import Benchmarker | |
loops = 1000 * 1000 | |
with Benchmarker(width=40) as bench: | |
@bench("static?") | |
def _(bm): | |
for _ in range(loops): | |
3.141592653589793 | |
@bench("pi") | |
def _(bm): | |
for _ in range(loops): | |
math.pi | |
@bench("acos(-1)") | |
def _(bm): | |
for _ in range(loops): | |
math.acos(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clombp% python3 pi.py | |
## benchmarker: release 4.0.1 (for python) | |
## python version: 3.4.1 | |
## python compiler: GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40) | |
## python platform: Darwin-15.0.0-x86_64-i386-64bit | |
## python executable: /usr/local/opt/python3/bin/python3.4 | |
## cpu model: Intel(R) Core(TM) i5-2435M CPU @ 2.40GHz | |
## parameters: loop=1, cycle=1, extra=0 | |
## real (total = user + sys) | |
static? 0.0830 0.0800 0.0800 0.0000 | |
pi 0.2338 0.2400 0.2300 0.0100 | |
acos(-1) 0.4723 0.4600 0.4600 0.0000 | |
## Ranking real | |
static? 0.0830 (100.0) ******************** | |
pi 0.2338 ( 35.5) ******* | |
acos(-1) 0.4723 ( 17.6) **** | |
## Matrix real [01] [02] [03] | |
[01] static? 0.0830 100.0 281.5 568.7 | |
[02] pi 0.2338 35.5 100.0 202.0 | |
[03] acos(-1) 0.4723 17.6 49.5 100.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment