Simple Benchmarking Library.
Project description
mbench
Simple benchmarking tool for a module, function, or block of code.
Profile Information for Block: test_func
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Duration │ 0.000616 seconds │
│ CPU time │ 0.000613 seconds │
│ Memory usage │ 1.00 KB │
│ GPU usage │ 1.00 KB │
│ I/O usage │ 1.00 KB │
│ Avg Duration │ 1.000000 seconds │
│ Avg CPU time │ 1.000000 seconds │
│ Avg Memory usage │ 1.00 KB │
│ Avg GPU usage │ 1.00 KB │
│ Avg I/O usage │ 1.00 KB │
│ Total calls │ 1 │
│ Notes │ │
└──────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Installation
pip install mbench
Usage
from mbench import profileme
profileme()
def some_function():
print("Hello")
some_function()
hello
Profile Information for Block: run_anything
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ Duration │ 0.000706 seconds │
│ CPU time │ 0.000668 seconds │
│ Memory usage │ 2.80 KB │
│ GPU usage │ 0.00 B │
│ I/O usage │ 0.00 B │
│ Avg Duration │ 0.000527 seconds │
│ Avg CPU time │ 0.000521 seconds │
│ Avg Memory usage │ 0.35 KB │
│ Avg GPU usage │ 0.00 B │
│ Avg I/O usage │ 0.00 B │
│ Total calls │ 8 │
│ Notes │ None │
└────────────────┴─────────────────────┘
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()
Caller Mode (Default)
Functions you want to profile must
- Be defined in the same module that the
profileme
function is being called. - Be called after
profileme(mode="caller")
is called.
Callee Mode
Functions you want to profile must
- Be called in the same module that the
profileme
function is being called. - Be called after
profileme(mode="callee")
is called.
License
mbench
is distributed under the terms of the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mbench-0.0.7.tar.gz
(16.5 kB
view hashes)
Built Distribution
mbench-0.0.7-py3-none-any.whl
(10.2 kB
view hashes)