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.
Release files for chronos-context-timer 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chronos_context_timer-1.0.0.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chronos_context_timer-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:13.8 kB
Release files / chronos_context_timer-1.0.0.tar.gz
| Download URL | chronos_context_timer-1.0.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07a7337a17b80131df2193028517c965177b87aabdb7f9831647a73e26363ccf
|
|
BLAKE2b-256 checksum How to use checksums |
8c65f97ab6381120345e29e4500c3e9a348a2d4148cc54ef4090bcda397fcd30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.
Transparency logRelease files / chronos_context_timer-1.0.0-py3-none-any.whl
| Download URL | chronos_context_timer-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f133c0081870434c729208c8fcefe588f1c43e656875ff3d9e08c505176f6543
|
|
BLAKE2b-256 checksum How to use checksums |
6a6a7e112472fc0d99ec3504946510dbe5a54b65e3b8cc39bd6bd9e1146dd349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2024.
Transparency log