Skip to main content

funcmeasure

Project description

funcmeasure

python_version PyPI downloads/month

Todo

  • Clean up code because it's a bit messy

Description

Measure and compare function execution times

Install

pip install funcmeasure
# or
pip3 install funcmeasure

Usage

from funcmeasure import measure, partial, Measurement

def f1():
    5**2

def f2():
    5**2**10

def f3():
    5**2**2**2

measurements = measure([f1, (f2, 'second'), f3], times=1000)

measurements = measure(
    {
        f1: None,
        f2: 'second',
        f3: None
    },
    times=1000
)

These will print:

Ran 1000 times

-------------------------------------------
| rank |  name  |   duration  | benchmark |
-------------------------------------------
|    1 |     f1 | 0.00000023s |           |
|    2 |     f3 | 0.00000026s |     1.12x |
|    3 | second | 0.00000263s |    11.22x |
-------------------------------------------

Ran 1000 times

-------------------------------------------
| rank |  name  |   duration  | benchmark |
-------------------------------------------
|    1 |     f3 | 0.00000024s |           |
|    2 |     f1 | 0.00000026s |     1.07x |
|    3 | second | 0.00000260s |    10.91x |
-------------------------------------------

Notes

The lib also provides a helper function for partials, so you don't have to import functools

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

funcmeasure-0.0.4.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

funcmeasure-0.0.4-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page