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

Uploaded Python 3

File details

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

File metadata

  • Download URL: time_checker-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d8f72d3a9364dd3ec6339eda6b9ebf9ea692434a53e61998480ff1bae13d6db3
MD5 43faf1b94548fabf128689987d748c9e
BLAKE2b-256 46e2e4ea51604a21fbc16cb7fe9b47e48ab9f1ef9c94076d7099c69fdb6ca32b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: time_checker-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f990fe7229ea243fb298f9f8ab4befdc14cccc97201a6346fdeafa1da846584
MD5 5382b9c90da353b33efdcc8fbb73bc26
BLAKE2b-256 013af61e9ba05b7d2e04c3157cbfceb1d9fc985b6529c8378096542402faff8b

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