Chronos: A Python library for advanced task timing with features like distributed timing, batch timing, real-time visualization, and debugging-friendly timers.
Project description
Chronos
Chronos is a Python library for advanced task timing, performance monitoring, and debugging tools. It is designed for developers who need precise control over timing tasks, distributed systems, batch processing, and more, with features like real-time visualization and debugging-friendly timers.
Features
- Base Timer: Core functionality for timing tasks with unit conversion, logging, and threshold warnings.
- ChronosTimer: A basic timer with all core features.
- DistributedChronosTimer: Aggregate timing data across distributed systems.
- BatchChronosTimer: Time multiple tasks and compute aggregate statistics.
- DebuggingChronosTimer: Pause and resume timers during debugging sessions.
- ChronosTimerWithVisualization: Real-time ASCII progress bars for task timing.
Installation
Install Chronos using pip:
pip install chronos-context-timer
Usage Examples
Basic Timer
from chronos import ChronosTimer
with ChronosTimer("Basic Task") as timer:
# Simulate some work
import time
time.sleep(1)
print(f"Task completed in {timer.get_elapsed('seconds')} seconds")
Distributed Timer
from chronos import DistributedChronosTimer
with DistributedChronosTimer("Distributed Task") as timer:
import time
time.sleep(1)
# Add external timings
timer.add_timing(0.5)
timer.add_timing(1.5)
print(f"Total elapsed time: {timer.get_total_time('seconds')} seconds")
Batch Timer
from chronos import BatchChronosTimer
def example_task():
import time
time.sleep(0.5)
batch_timer = BatchChronosTimer("Batch Example")
for _ in range(3):
batch_timer.time_task(example_task)
stats = batch_timer.get_statistics("seconds")
print(f"Average time: {stats['average_time']} seconds")
print(f"Total time: {stats['total_time']} seconds")
Debugging Timer
from chronos import DebuggingChronosTimer
with DebuggingChronosTimer("Debug Task") as timer:
input("Press Ctrl+Z to pause, and again to resume. Press Enter to finish.")
Timer with Visualization
from chronos import ChronosTimerWithVisualization
with ChronosTimerWithVisualization("Visualized Task", interval=0.2, threshold=5):
import time
time.sleep(5)
Development
Running Tests
Run all tests using pytest:
pytest tests/
Type Checking
Chronos is fully type-checked using mypy. To run type checks:
mypy chronos/
License
Chronos is licensed under the MIT License. See LICENSE for details.
Documentation
Complete documentation is available here.
Project details
Release history Release notifications | RSS feed
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 chronos_context_timer-1.0.0.tar.gz.
File metadata
- Download URL: chronos_context_timer-1.0.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07a7337a17b80131df2193028517c965177b87aabdb7f9831647a73e26363ccf
|
|
| MD5 |
6b80a74051b86647f14bc3b00fa5aeca
|
|
| BLAKE2b-256 |
8c65f97ab6381120345e29e4500c3e9a348a2d4148cc54ef4090bcda397fcd30
|
Provenance
The following attestation bundles were made for chronos_context_timer-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on adambirds/chronos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chronos_context_timer-1.0.0.tar.gz -
Subject digest:
07a7337a17b80131df2193028517c965177b87aabdb7f9831647a73e26363ccf - Sigstore transparency entry: 153415151
- Sigstore integration time:
-
Permalink:
adambirds/chronos@ffca4eb2ee319a8c7571fdc22e2f12b3bd8240d2 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/adambirds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ffca4eb2ee319a8c7571fdc22e2f12b3bd8240d2 -
Trigger Event:
create
-
Statement type:
File details
Details for the file chronos_context_timer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: chronos_context_timer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f133c0081870434c729208c8fcefe588f1c43e656875ff3d9e08c505176f6543
|
|
| MD5 |
aef7faa47a299081291d5709498228e4
|
|
| BLAKE2b-256 |
6a6a7e112472fc0d99ec3504946510dbe5a54b65e3b8cc39bd6bd9e1146dd349
|
Provenance
The following attestation bundles were made for chronos_context_timer-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on adambirds/chronos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chronos_context_timer-1.0.0-py3-none-any.whl -
Subject digest:
f133c0081870434c729208c8fcefe588f1c43e656875ff3d9e08c505176f6543 - Sigstore transparency entry: 153415152
- Sigstore integration time:
-
Permalink:
adambirds/chronos@ffca4eb2ee319a8c7571fdc22e2f12b3bd8240d2 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/adambirds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ffca4eb2ee319a8c7571fdc22e2f12b3bd8240d2 -
Trigger Event:
create
-
Statement type: