[ANN] Benchmarker 2.0.0 released - a samll benchmark utility

K

kwatch

I released Benchmarker 2.0.0.
http://pypi.python.org/pypi/Benchmarker/

Benchmarker is a small utility to benchmark your code.


Download
--------

http://pypi.python.org/pypi/Benchmarker/

Installation::

## if you have installed easy_install:
$ sudo easy_install Benchmarker
## or download Benchmarker-X.X.X.tar.gz and install it
$ wget http://pypi.python.org/packages/source/B/Benchmarker/Benchmarker-X.X.X.tar.gz
$ tar xzf Benchmarker-X.X.X.tar.gz
$ cd Benchmarker-X.X.X/
$ sudo python setup.py install


Example for Busy People
-----------------------

ex0.py::

from __future__ import with_statement
from benchmarker import Benchmarker
s1, s2, s3, s4, s5 = "Haruhi", "Mikuru", "Yuki", "Itsuki", "Kyon"
with Benchmarker(loop=1000*1000) as bm:
for i in bm.empty(): ## empty loop
pass
for i in bm('"".join((s,s,s))'):
sos = "".join((s1, s2, s3, s4, s5))
for i in bm('s+s+s'):
sos = s1 + s2 + s3 + s4 + s5
for i in bm('"%s%s%s" % (s,s,s)'):
sos = "%s%s%s%s%s" % (s1, s2, s3, s4, s5)

Output::

$ python ex0.py
## benchmarker: release 0.0.0 (for python)
## python platform: darwin [GCC 4.2.1 (Apple Inc. build 5659)]
## python version: 2.5.5
## python executable: /usr/local/python/2.5.5/bin/python

## Benchmark user sys total
real
(Empty) 0.1200 0.0300 0.1500
0.1605
"".join((s,s,s)) 0.7300 -0.0300 0.7000
0.6992
s+s+s 0.6600 -0.0200 0.6400
0.6321
"%s%s%s" % (s,s,s) 0.8700 -0.0300 0.8400
0.8305

## Ranking real ratio chart
s+s+s 0.6321 (100.0)
********************
"".join((s,s,s)) 0.6992 ( 90.4)
******************
"%s%s%s" % (s,s,s) 0.8305 ( 76.1) ***************

## Ratio Matrix real [01] [02] [03]
[01] s+s+s 0.6321 100.0 110.6 131.4
[02] "".join((s,s,s)) 0.6992 90.4 100.0 118.8
[03] "%s%s%s" % (s,s,s) 0.8305 76.1 84.2 100.0


See http://pypi.python.org/pypi/Benchmarker/ for more details.


Changes from 1.1.0
------------------

* Rewrited entirely.

* Enhance to support empty loop. Result of empty loop is subtracted
automatically automatically from other benchmark result. ::

bm = Benchmarker()
with bm.empty():
for i in xrange(1000*1000):
pass
with bm('my benchmark 1'):
#... do something ...

* Enhance to support for-statement. ::

bm = Benchmarker(loop=1000*1000)
for i in bm('example'):
#... do something ...

## the above is same as:
bm = Benchmarker()
with bm('example'):
for i in xrange(1000*1000):
#... do something ...

* Enhance to support new feature to repeat benchmarks. ::

bm = Benchmarker()
for b in bm.repeat(5): # repeat benchmark 5 times
with b('example1'):
#... do something ...
with b('example2'):
#... do something ...

* 'compared_matrix()' is replaced by 'stat.all()'.
'stat.all()' shows benchmark ranking and ratio matrix. ::

bm = Benchmarker()
with bm('example'):
# ....
print(bm.stat.all()) # ranking and ratio matrix

* Enhance to support 'Benchmark.platform()' which gives you platform
information. ::

print bm.platform()
#### output example
## benchmarker: release 2.0.0 (for python)
## python platform: darwin [GCC 4.2.1 (Apple Inc. build 5659)]
## python version: 2.5.5
## python executable: /usr/local/python/2.5.5/bin/python2.5

* 'with-statement' for benchmarker object prints platform info and
statistics
automatically. ::

with Benchmarker() as bm:
wtih bm('fib(30)'):
fib(30)
#### the above is same as:
# bm = Benchmarker()
# print(bm.platform())
# with bm('fib(30)'):
# fib(30)
# print(bm.stat.all())

* Enhance Benchmarker.run() to use function docment (__doc__) as
benchmark
label when label is not specified. ::

def fib(n):
"""fibonacchi"""
return n <= 2 and 1 or fib(n-1) + fib(n-2)
bm = Benchmarker()
bm.run(fib, 30) # same as bm("fibonacchi").run(fib, 30)

* Default format of times is changed from '%9.3f' to '%9.4f'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top