Skip to main content

Ergonomic interface to Python's built-in timeit.

Project description

uv Python Version from PEP 621 TOML PyPI - Implementation GitHub Actions Workflow Status PyPI - Wheel GitHub License

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.0a2.tar.gz (4.0 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.0a2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: benchmarkme-0.1.0a2.tar.gz
  • Upload date:
  • Size: 4.0 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.0a2.tar.gz
Algorithm Hash digest
SHA256 70e8cb574ead239887f378ad0bbd74611453dd8bd27b084ab42f4f08e5ac1edc
MD5 b2f0f473b69d848b6b2191ff65f96eaf
BLAKE2b-256 130331b7db979a50866e858ac21f825f71cdc72db4ecdf35079be204c5ec95bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: benchmarkme-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7bc85cd4906798e112335fb1d616453c49c2c2c9f756d653289864a1ce6654e
MD5 3c5d389af3d6fbbfa068db0e08780ab2
BLAKE2b-256 13077721fb190119f7e04796d1cd36c94fc9de26e67ee433f92d73783d7c395b

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