Skip to main content

A simple utility class for timing and tracing code execution. Mark operations and print elapsed times between them.

Project description

TimeTracer

A simple utility for timing code execution.

Installation

Using uv (recommended)

uv add timingtracer

Using pip

pip install timingtracer

Usage

start/end

from timingtracer import TimeTracer

tt = TimeTracer("MyModule")
tt.start("fetch data")
# ... code to measure ...
tt.end()

Output: [MyModule] - fetch data took 10.5ms

Context manager

from timingtracer import TimeTracer

with TimeTracer("MyModule", "fetch data"):
    # ... code to measure ...
    pass

Or with method chaining:

with TimeTracer("MyModule").operation("fetch data"):
    # ... code to measure ...
    pass

Output: [MyModule] - fetch data took 10.5ms

Get elapsed time

tt = TimeTracer("MyModule")
tt.start("fetch data")
# ... code to measure ...
elapsed = tt.end()

print(f"It took {elapsed:.3f}s")

API

  • TimeTracer(tracer="TimeTracer") - Create a tracer with a name for your module
  • tt.start(operation_name) - Start timing an operation
  • tt.end() - Stop timing and print elapsed time
  • tt.elapsed - Get elapsed time in seconds (after calling end())
  • tt.operation(name) - Set operation name for context manager chaining

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

timingtracer-0.1.2.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timingtracer-0.1.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file timingtracer-0.1.2.tar.gz.

File metadata

  • Download URL: timingtracer-0.1.2.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for timingtracer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a04ae83d30ebcba499e2bffc52238111df61294a24266801dbed8a14dd26a3e0
MD5 58b8b266311a4e2272a36b6512439c00
BLAKE2b-256 3f11733d29b6f61625eafdeab3486547890f048ebb20c591cb3881c47b0a8be1

See more details on using hashes here.

File details

Details for the file timingtracer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: timingtracer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for timingtracer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5b708cc1a67018bdbffa73eaf37e1795434cd1bf6d715d118ca9a8e91541d215
MD5 0e28e93b16d1257df6e11b19b0c580f0
BLAKE2b-256 08fa03009c6678a9971f18df12798f0b5ce8bd1dfcc694a808b0c26a4066f7f4

See more details on using hashes here.

Supported by

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