Skip to main content

A simple Python package for timing functions and code blocks

Project description

pytasktimer

A simple Python package for timing functions and code blocks.

Installation

pip install pytasktimer

Usage

Using the Timer context manager

from pytasktimer import Timer

with Timer("my task"):
    time.sleep(1)

Using the decorator

from pytasktimer import time_function

@time_function
def my_function():
    time.sleep(0.5)

my_function()

Using the decorator that returns elapsed time

from pytasktimer import time_function_with_return

@time_function_with_return
def compute():
    time.sleep(0.3)
    return 42

result, elapsed = compute()
print(f"Result: {result}, elapsed: {elapsed}")

License

MIT

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

pytasktimer-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

pytasktimer-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file pytasktimer-0.1.0.tar.gz.

File metadata

  • Download URL: pytasktimer-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for pytasktimer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ffd6715c05eb830def7c8fbb4d42be5e1cc0c1f882b32996f6ed12e89dac1f3c
MD5 83e54d20ea4994decfc56e78eda879dc
BLAKE2b-256 8fd9ba0dcf0588b2898089ac3b225d46e74ca4237baa71eee14a3e6ee3974185

See more details on using hashes here.

File details

Details for the file pytasktimer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytasktimer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for pytasktimer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66789498b0d8fc7c498389d6d0c5ac2a991ac420291e01ac8df59a3c34982e00
MD5 765d6c7697cba10505f5896e68da14ed
BLAKE2b-256 d932f4084135c4c25a1dd307d1698b9c88bd96d023e36021b6d8d122d10e498c

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