ANN: Benchmarker 4.0.0 released - small but awesome benchmark utility
Makoto Kuwata
kwa at kuwata-lab.com
Mon Dec 15 07:43:26 EST 2014
I released Benchmarker ver 4.0.0
http://pypi.python.org/pypi/Benchmarker/
http://pythonhosted.org/Benchmarker/
Benchmarker is a small utility to benchmark your code.
*NOTICE* This release doesn't have compatibility with ver 3.x.
Installation
------------
$ sudo pip install Benchmarker
Example
-------
example.py::
from benchmarker import Benchmarker
with Benchmarker(1000*1000, width=20) as bench:
s1, s2, s3, s4, s5 = "Haruhi", "Mikuru", "Yuki", "Itsuki", "Kyon"
@bench(None)
def _(bm):
for _ in bm: ## empty loop
pass
@bench("concat")
def _(bm):
for _ in bm:
s = s1 + s2 + s3 + s4 + s5
@bench("join")
def _(bm):
for _ in bm:
s = "".join((s1, s2, s3, s4, s5))
@bench("format")
def _(bm):
for _ in bm:
s = "%s%s%s%s%s" % (s1, s2, s3, s4, s5)
Output example::
$ python example.py -h # show help message.
$ python example.py # or python example.py -n 1000000
## benchmarker: release 4.0.0 (for python)
## python version: 3.4.1
## python compiler: GCC 4.2.1 Compatible Apple LLVM 6.0
(clang-600.0.51)
## python platform: Darwin-14.0.0-x86_64-i386-64bit
## python executable: /usr/local/bin/python
## cpu model: Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
## parameters: loop=1000000, cycle=1, extra=0
## real (total = user + sys)
(Empty) 0.0335 0.0300 0.0300 0.0000
concat 0.4192 0.4200 0.4100 0.0100
join 0.3674 0.3700 0.3700 0.0000
format 0.4765 0.4600 0.4600 0.0000
## Ranking real
join 0.3674 (100.0) ********************
concat 0.4192 ( 87.6) ******************
format 0.4765 ( 77.1) ***************
## Matrix real [01] [02] [03]
[01] join 0.3674 100.0 114.1 129.7
[02] concat 0.4192 87.6 100.0 113.7
[03] format 0.4765 77.1 88.0 100.0
Notice that empty loop times (real, user, sys and total) are
subtracted from other benchmark times automatically.
For example::
===================================================
benchmark label real (second)
---------------------------------------------------
join 0.3674 (= 0.4009 - 0.0335)
concat 0.4192 (= 0.4527 - 0.0335)
format 0.4765 (= 0.5100 - 0.0335)
===================================================
See http://pythonhosted.org/Benchmarker/ for details.
Have fun!
--
regards,
makoto kuwata
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141215/721208e1/attachment.html>
More information about the Python-list
mailing list