Skip to main content

Python benchmarker/benchmarking framework

Project description

benchmark is a Python benchmarking framework, similar to Steve Purcell’s unittest in basic structure. It’s as simple as:

import benchmark

import math

class Benchmark_Sqrt(benchmark.Benchmark):

    def test_pow_operator(self):
        for i in xrange(750000):
            z = i**.5

    def test_pow_function(self):
        for i in xrange(750000):
            z = pow(i, .5)

    def test_sqrt_function(self):
        for i in xrange(750000):
            z = math.sqrt(i)

if __name__ == '__main__':
    benchmark.main(each=50, format="markdown")

which produces:

Benchmark Report
================

Benchmark Sqrt
--------------

         name | rank | runs |           mean |               sd
--------------|------|------|----------------|-----------------
 pow operator |    1 |   50 | 0.113651094437 | 0.00709087316343
sqrt function |    2 |   50 | 0.151987323761 | 0.00658830515608
 pow function |    3 |   50 | 0.223314394951 |  0.0133163421349

The functions above were run in random, nonconsecutive order by
`benchmark` v0.1.0 (http://jspi.es/benchmark) with Python 2.7.1
Darwin-11.3.0-x86_64 on 2012-04-16 17:42:19.

More examples are available in the example folder or visit http://jspies.com/benchmark for more information.

Project details


Download files

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

Source Distribution

benchmark-0.1.1.tar.gz (6.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page