Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kkristof200/py_funcmeasure
funcmeasure
https://github.com/kkristof200/py_funcmeasure
Last synced: 10 days ago
JSON representation
funcmeasure
- Host: GitHub
- URL: https://github.com/kkristof200/py_funcmeasure
- Owner: kkristof200
- License: mit
- Created: 2020-06-07T22:27:17.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-15T15:14:31.000Z (over 3 years ago)
- Last Synced: 2024-10-08T02:49:45.200Z (about 1 month ago)
- Language: Python
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# funcmeasure
![PyPI - package version](https://img.shields.io/pypi/v/funcmeasure?logo=pypi&style=flat-square)
![PyPI - license](https://img.shields.io/pypi/l/funcmeasure?label=package%20license&style=flat-square)
![PyPI - python version](https://img.shields.io/pypi/pyversions/funcmeasure?logo=pypi&style=flat-square)
![PyPI - downloads](https://img.shields.io/pypi/dm/funcmeasure?logo=pypi&style=flat-square)![GitHub - last commit](https://img.shields.io/github/last-commit/kkristof200/py_funcmeasure?style=flat-square)
![GitHub - commit activity](https://img.shields.io/github/commit-activity/m/kkristof200/py_funcmeasure?style=flat-square)![GitHub - code size in bytes](https://img.shields.io/github/languages/code-size/kkristof200/py_funcmeasure?style=flat-square)
![GitHub - repo size](https://img.shields.io/github/repo-size/kkristof200/py_funcmeasure?style=flat-square)
![GitHub - lines of code](https://img.shields.io/tokei/lines/github/kkristof200/py_funcmeasure?style=flat-square)![GitHub - license](https://img.shields.io/github/license/kkristof200/py_funcmeasure?label=repo%20license&style=flat-square)
## Description
Measure and compare function execution times
## Install
~~~~bash
pip install funcmeasure
# or
pip3 install funcmeasure
~~~~## Usage
~~~~python
from funcmeasure import measure, FunctionStats, TableFormatdef f1():
5**2def f2():
5**2**10def f3():
5**2**2**2# stats = measure([f1, (f2, 'second'), f3], times=1000)
# or
stats = measure(
{
f1: None,
f2: 'second',
f3: None
},
times=1000
)# prints
#
# Ran 3 functions. 1000 times each.
#
# ╒════╤════════╤════════════╤══════════════╤═════════════╤══════════════╤═════════════╕
# │ │ Name │ Avg (ms) │ Total (ms) │ Best (ms) │ Worst (ms) │ Benchmark │
# ╞════╪════════╪════════════╪══════════════╪═════════════╪══════════════╪═════════════╡
# │ 0 │ f3 │ 0.002123 │ 2.122589 │ 0.001892 │ 0.007872 │ │
# ├────┼────────┼────────────┼──────────────┼─────────────┼──────────────┼─────────────┤
# │ 1 │ f1 │ 0.002282 │ 2.281747 │ 0.001952 │ 0.062483 │ ~1.07x │
# ├────┼────────┼────────────┼──────────────┼─────────────┼──────────────┼─────────────┤
# │ 2 │ second │ 0.004946 │ 4.946447 │ 0.004395 │ 0.053278 │ ~2.33x │
# ╘════╧════════╧════════════╧══════════════╧═════════════╧══════════════╧═════════════╛
~~~~## Dependencies
[jsoncodable](https://pypi.org/project/jsoncodable), [tabulate](https://pypi.org/project/tabulate)