A reusable timer utility for Python scripts
Project description
Code-Time: A Reusable Timer Utility for Python Scripts
Code-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 Code-Time-Checker using pip:
pip install code-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 code_timechecker 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 code_time 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 code_time 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
- Deep Korat
GitHub Profile | Email
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file time_checker-0.0.1.tar.gz.
File metadata
- Download URL: time_checker-0.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba6840a49b6764316791027107cb2da61cb06005f736d95c2e9911e98da390c7
|
|
| MD5 |
884ef746648a869c786dc794616922cd
|
|
| BLAKE2b-256 |
629437424ebbae1cb602a8e42435e993cda70aa337cb6b9833cc336df1bcd6d6
|
File details
Details for the file time_checker-0.0.1-py3-none-any.whl.
File metadata
- Download URL: time_checker-0.0.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cba8f16b4b52fa191bf214da5579f18d325bdf68317e42738f7b557d20ac85c
|
|
| MD5 |
38dde423c4215f7568a46a00d98567b9
|
|
| BLAKE2b-256 |
0b8a4c6a7a35292f87513743a84621d055c5507c12ddfb781b0412ec6a93d03e
|