Skip to content

mbodiai/mbench

Repository files navigation

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.

About

Simple Benchmarking Tool

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages