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"):
    tt.start("fetch data")
    # ... code to measure ...
    tt.end()

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 (default: "Operation")
  • tt.end() - Stop timing and print elapsed time
  • tt.elapsed - Get elapsed time in seconds (after calling end())

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.5.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.5-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: timingtracer-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 d0faef21f12ff22316243560ae3317c6bc5dc521b91153daf79300e4a3e7feb7
MD5 ed2b9587b22c58fc36fef0fa26f88175
BLAKE2b-256 8f3b3a68c8c7459b015b4797d39c14f00d913452c545898a575513f4531ce101

See more details on using hashes here.

File details

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

File metadata

  • Download URL: timingtracer-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 3.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 84ec87bdf888021499933476764cd7052372ce79cfdb90e2a4e7cc7f9ded026e
MD5 bfdaa57fc79253aa3e01f53efc616a41
BLAKE2b-256 5e1e1411cf675c30d0136f3ffb764e57b10f4c4f8dac611ea9ab1c5cf48ba51f

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