Skip to main content

a small utility for benchmarking

Project description

Benchmarker is a small utility to benchmark your code.

Example (ex.py):

def fib(n):
    return n <= 2 and 1 or fib(n-1) + fib(n-2)
from benchmarker import Benchmarker
bm = Benchmarker()  # or Benchmarker(width=30, out=sys.stderr, header=True)
## Python 2.5 or later
with bm('fib(n) (n==34)'):  fib(34)
with bm('fib(n) (n==35)'):  fib(35)
## Python 2.4
bm('fib(n) (n==34)').run(lambda: fib(34))
bm('fib(n) (n==35)').run(lambda: fib(35))

Output:

$ python ex.py
                                   utime      stime      total       real
fib(n) (n==34)                    4.3700     0.0200     4.3900     4.9449
fib(n) (n==35)                    7.1500     0.0500     7.2000     8.0643

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Benchmarker, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size Benchmarker-1.0.0-py2.4.egg (4.4 kB) File type Egg Python version 2.4 Upload date Hashes View
Filename, size Benchmarker-1.0.0-py2.5.egg (4.3 kB) File type Egg Python version 2.5 Upload date Hashes View
Filename, size Benchmarker-1.0.0-py2.6.egg (4.4 kB) File type Egg Python version 2.6 Upload date Hashes View
Filename, size Benchmarker-1.0.0-py2.7.egg (4.3 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size Benchmarker-1.0.0.tar.gz (8.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page