Skip to main content

funcmeasure

Project description

funcmeasure

PyPI - package version PyPI - license PyPI - python version PyPI - downloads

GitHub - last commit GitHub - commit activity

GitHub - code size in bytes GitHub - repo size GitHub - lines of code

GitHub - license

Description

Measure and compare function execution times

Install

pip install funcmeasure
# or
pip3 install funcmeasure

Usage

from funcmeasure import measure, FunctionStats, TableFormat

def f1():
    5**2

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

def 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, tabulate

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.1.2.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

funcmeasure-0.1.2-py3-none-any.whl (8.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