Skip to main content

executiontimer

PyPI version Python versions CI License Documentation

Time named sections of your code with a with block or a decorator. Sections nested inside each other form a tree, so you see where the time actually went, not just one number at the end.

Zero dependencies. Fully typed. Works with threads and asyncio.

Documentation

seba2390.github.io/ExecutionTimer

Installation

pip install executiontimer

Requires Python 3.11+. The install name is executiontimer; the import name is execution_timer.

Quick start

import time

from execution_timer import TimerContext, get_execution_times_report

with TimerContext("load_data"):
    time.sleep(0.12)

with TimerContext("solve"):
    for i in range(3):
        with TimerContext("step", category="gpu", counter=i):
            time.sleep(0.05)
    with TimerContext("postprocess", category="cpu"):
        time.sleep(0.03)

print(get_execution_times_report())
Total time: 312.838 ms.

load_data: 124.682 ms (39.85%)
solve: 188.157 ms (60.15%)
..  step: 154.718 ms (49.46%)
..  postprocess: 33.295 ms (10.64%)

TimerContext also works as a decorator, including on async def functions:

@TimerContext("preprocess")
def preprocess(rows: list[str]) -> list[str]:
    return [row.strip() for row in rows]

Learn more

License

MIT — see LICENSE.

Metadata

Release files for executiontimer 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for executiontimer 1.1.0
File Size Uploaded
executiontimer-1.1.0.tar.gz 38.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for executiontimer 1.1.0
File Interpreter ABI Platform
executiontimer-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 49.2 kB

Release files / executiontimer-1.1.0.tar.gz

Download URL executiontimer-1.1.0.tar.gz
Size 38.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88b17883cb3bd8d249b98c7e6c527379c8237c74e592c289df855938754cb21d
BLAKE2b-256 checksum
How to use checksums
c907fe1799d04a0aa87b9b79ebddae35d59f22b72374511ac867d9941f7133ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / executiontimer-1.1.0-py3-none-any.whl

Download URL executiontimer-1.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f569af8f26504c90e24dd6217e0bf7c06634a6d50150bbf181f46b209deb110f
BLAKE2b-256 checksum
How to use checksums
e971f3ad4b9d846250f8bb61e2fe14afcea17620954802e8faa29f03f3eddd7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.1

2 release files

This release

1.1.0 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page