Skip to main content

Ergonomic interface to Python's built-in timeit.

Project description

uv Python Version from PEP 621 TOML

benchmarkme

Ergonomic Python interface to the built-in timeit utility for quick-look profiling.

Out-Of-The-Box Features

  • Python API with enhanced reporting
  • Yields configuration, best & worst times and processing rates
  • Default autoranging
  • Automatic looping & repeat
  • Customizable environment

Usage

Minimal example

>>> from time import sleep
>>> from benchmarkme import BenchMark
>>> b = BenchMark(f=sleep, fargs=[0.2,])
>>> b() # call the instance directly to run the main utility
Benchmark Results
-----------------
* Ran 1 trials 5 times.
* Time of one independent trial: 200 msec
* Best time of subsequent trials: 200 msec
* Worst time of subsequent trials: 200 msec
* Best speed: 5 items / sec
* Worst speed: 4.99 items / sec

Provide the items processed to get rate in the desired units (from benchmarkme/examples/basic.py)

import math
from benchmarkme import BenchMark

def fmath(x: list) -> None:
    """Calculate somethig complex-looking to time."""        
    return [math.log(math.acos(item / 1e5)) ** 2 / 1733 for item in x]

items = 100000
bmrk_math = BenchMark(
    f=fmath, 
    fargs=[[*range(items)],], 
    item_units='numbers', 
    items_processed=items
)

if __name__ == "__main__":
    bmrk_math()

You'll get something like the following, i.e. the function computes around 10 million numbers per second on this machine.

Benchmark Results
-----------------
* Ran 50 trials 5 times.
* Time of one independent trial: 8.92 msec
* Best time of subsequent trials: 8.89 msec
* Worst time of subsequent trials: 12.1 msec
* Best speed: 11.2 Mnumbers / sec
* Worst speed: 8.28 Mnumbers / sec

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

benchmarkme-0.1.0a1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

benchmarkme-0.1.0a1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file benchmarkme-0.1.0a1.tar.gz.

File metadata

  • Download URL: benchmarkme-0.1.0a1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for benchmarkme-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 8629ab389484926d7ccd5dd59970b53314a2d395255c54a3f3453a1858b8d997
MD5 e137b42afc99a872e1b779ad151a6245
BLAKE2b-256 5659ab39745cfac811dcc193e9e5049906d0209fe1ef3c4cbab90d8ca512c6e9

See more details on using hashes here.

File details

Details for the file benchmarkme-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: benchmarkme-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for benchmarkme-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b7fb79e9fbf2e71088390968920606d3222758883e994381a146aeca3ea78d4
MD5 de824ed9b9a504a5d1eb90a98834e097
BLAKE2b-256 1905ee9ee30cf17749b39ef040f8275ebf927d92b3a7534940b252ef5fcf61dc

See more details on using hashes here.

Supported by

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