Skip to main content

A reusable timer utility for Python scripts

Project description

Code-Time: A Reusable Timer Utility for Python Scripts

time-checker is a lightweight and reusable Python package for measuring the execution time of scripts, functions, and code blocks. It’s perfect for developers who want to profile their Python code quickly.

Features

  • Function Timing: Use a decorator to measure the execution time of any function.
  • Code Block Timing: Use a context manager to time specific blocks of code.
  • Script Timing: Easily measure the total execution time of your Python script.

Installation

Install Time-Checker using pip:

pip install time-checker

Usage

1. Timing Code Blocks

Use the time_block context manager to measure the time taken by a specific block of code:

from time_checker import time_block

with time_block("Processing Loop"):
    for _ in range(10**6):
        pass

Output:

Processing Loop executed in 0.1234 seconds

2. Timing Functions

Use the time_function decorator to measure the time taken by any function:

from time_checker import time_function

@time_function
def example_function():
    for _ in range(10**7):
        pass

example_function()

Output:

Function 'example_function' executed in 0.4567 seconds

3. Timing an Entire Script

Use the script_timer utility to measure the total execution time of a script:

from time_checker import script_timer

with script_timer():
    print("Starting script...")
    for _ in range(10**6):
        pass
    print("Script complete.")

Output:

Starting script...
Script complete.
Script executed in 0.7890 seconds

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Author

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

time_checker-0.0.3.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

time_checker-0.0.3-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file time_checker-0.0.3.tar.gz.

File metadata

  • Download URL: time_checker-0.0.3.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for time_checker-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d133b20f3c332176cef045fab388fee4aed8a04798d5a66af0b2ead4a774e63b
MD5 793cfe49605abf9782cd9c2381dcac3d
BLAKE2b-256 cbc590b3419bbda24f1a2e36864524cbd16e68c5fcb04b6f4b9256735ab30598

See more details on using hashes here.

File details

Details for the file time_checker-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: time_checker-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for time_checker-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ddb78d13345e1b9dd398c8fdf710fbd150a05dcdee3c717b3c78585581297404
MD5 242e7314c5c8ae9e95bddcd323ace111
BLAKE2b-256 1e9ec1c8b065a950a18fd48f020a68b8527142d4e705e2a1686dc364fb383812

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