Skip to main content

mbench

PyPI - Version PyPI - Python Version


Simple benchmarking tool for a module, function, or block of code.

Installation

pip install mbench

Usage

from mbench import profileme
profileme()

def some_function():
    print("Hello")

some_function()
        Profile Information for         
     __main__.test_get_object_speed     
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃           Metric ┃ Value             ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│         Duration │ 1.461318 seconds  │
│         CPU time │ 24.613764 seconds │
│     Memory usage │ 250.56 MB         │
│        GPU usage │ 0.00 B            │
│       GPU usages │                   │
│        I/O usage │ 0.00 B            │
│     Avg Duration │ 0.292264 seconds  │
│     Avg CPU time │ 4.922753 seconds  │
│ Avg Memory usage │ 50.11 MB          │
│    Avg GPU usage │ 0.00 B            │
│   Avg GPU usages │                   │
│    Avg I/O usage │ 0.00 B            │
│      Total calls │ 5                 │
└──────────────────┴───────────────────┘

As a Decorator

from mbench import profile
@profile
def some_function():
    print("Hello")

As a Context Manager

from mbench import profiling
with profiling:
  run_anything()

when calling

Functions you want to profile must

  1. Be defined in the same module that the profileme function is being called.
  2. Be called after profileme(when="calling") is called.

when called

Functions you want to profile must

  1. Be called in the same module that the profileme function is being called.
  2. Be called after profileme(when="called") is called.

Docs

profileme(when: Literal['called', 'calling'] = 'called')
    Profile all functions in a module. Set `when` to 'calling' to profile only the functions called by the target module.

License

mbench is distributed under the terms of the MIT License.

Metadata

Release files for mbench 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mbench 0.0.11
File Size Uploaded Provenance Actions
mbench-0.0.11.tar.gz 11.9 kB Without provenance Details for mbench-0.0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mbench 0.0.11
File Interpreter ABI Platform Actions
mbench-0.0.11-py3-none-any.whl Python 3 none any Details for mbench-0.0.11-py3-none-any.whl

Total release size: 24.2 kB

Release files / mbench-0.0.11.tar.gz

Download URL mbench-0.0.11.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4c641e8fca748d93b7edb6e2b5d8fe70731e37c43d4f8019efeca850bafe5550
BLAKE2b-256 checksum
How to use checksums
970becc5cc451a47a7cab8e9499dda4eafd0034b51b0aeab4880bd789d28e5c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / mbench-0.0.11-py3-none-any.whl

Download URL mbench-0.0.11-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
caf4d73cad4d16403fd6daf5d69172118d54ed935271b22025aec494bd43199c
BLAKE2b-256 checksum
How to use checksums
f40077563a475b269faacd118a61c5072d16df66dce6df4d157630c6573d1a50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Security for mbench 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page