Skip to main content

yet another random library for measuring python performance

Project description

Timeitpoj

yet another random library for measuring python performance

Build and Test PyPI version

Usage in production

if you do not need to measure performance of your code in a production environment, simply set the environment variable TIME_IT tofalse

Example

from timeitpoj.timeit import TimeIt
from time import sleep

BASE_TIME = 0.1

with TimeIt("my timer") as timer:
    print("Executing my timer....")
    sleep(BASE_TIME)

    with timer("my subtimer"):
        print("Executing my subtimer....")
        sleep(BASE_TIME)

        with timer("my nested subtimer"):
            print("Executing my nested subtimer....")
            sleep(BASE_TIME)

            for _ in range(2):
                with timer("my super nested subtimer 2"):
                    sleep(BASE_TIME)

        for _ in range(5):
            with timer("my nested subtimer 2"):
                sleep(BASE_TIME)

    with timer("my subtimer 992"):
        print("Executing my subtimer 2....")
        sleep(BASE_TIME)

    with timer("my subtimer 4"):
        print("Executing my subtimer 4....")
        sleep(BASE_TIME)

    # Something that is not covered by the timer
    sleep(BASE_TIME * 2)

Output

================= [my timer] TIMEIT REPORT =================
[TIMEIT] my timer took 1.403 seconds
└── [81.80%] my subtimer ; 0.902 seconds
    ├── [37.49%] my nested subtimer ; 0.300 seconds
        └── my super nested subtimer 2 ; 0.200 seconds ; 2 times ; avg 0.100 seconds
    └── [62.51%] my nested subtimer 2 ; 0.501 seconds ; 5 times ; avg 0.100 seconds
├── [ 9.12%] my subtimer 992 ; 0.101 seconds
└── [ 9.08%] my subtimer 4   ; 0.100 seconds
└── [ 0.01%] internal time: 0.112 milliseconds
[78.56%% COVERAGE] time accounted for: 1.102 seconds, time unaccounted for: 0.301 seconds
[TIMEIT] report generation took 0.190 milliseconds
================= [my timer] TIMEIT REPORT =================

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

timeitpoj-0.1.11.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

timeitpoj-0.1.11-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file timeitpoj-0.1.11.tar.gz.

File metadata

  • Download URL: timeitpoj-0.1.11.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/6.1.70-1-lts

File hashes

Hashes for timeitpoj-0.1.11.tar.gz
Algorithm Hash digest
SHA256 6a5f27b923e98d90f0e9816c1cead3c052e1aa51c4f0ce86fe5be8de264ad371
MD5 cb80e11d62c86a52bed4d97c35bc0111
BLAKE2b-256 e6f58ee1fce1bade0bcf13d1350f6a35094bfd8b2fda630552f393ac2f46c85f

See more details on using hashes here.

File details

Details for the file timeitpoj-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: timeitpoj-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/6.1.70-1-lts

File hashes

Hashes for timeitpoj-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 4d5e719b6f94ba2fb8061dc4d442780611dc806224eb774ac21d571e09527bfb
MD5 f205b786fa6fadeadddbf0a9267a87f6
BLAKE2b-256 0cdcf75ce8782c27f154b45f8d0f10f4348ae5628041a0340c6088298c96cd86

See more details on using hashes here.

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