A simple and intuitive timer library for measuring elapsed time
Project description
EZTimer
A simple and intuitive Python timer library for measuring elapsed time with comprehensive pause/resume functionality.
Installation
pip install py-eztimer
## Quick Start
from eztimer import EZTimer
import time
# Basic usage
timer = EZTimer()
timer.start()
# Do some work...
time.sleep(1.5)
print(f"Elapsed time: {timer.get_elapsed_time():.2f} seconds")
# Pause/resume functionality
timer.pause()
time.sleep(1) # This won't be counted
timer.resume()
time.sleep(0.5)
print(f"Total time: {timer.get_elapsed_time():.2f} seconds")
# Reset and restart
timer.restart()
## API Reference
start()
Start the timer. If already running, has no effect.
pause()
Pause the timer, freezing the current elapsed time.
resume()
Resume a paused timer, continuing from where it left off.
get_elapsed_time() -> float
Get the total elapsed time in seconds.
reset()
Completely reset the timer to zero.
restart()
Reset the timer and immediately start counting again.
## Examples
Benchmarking Code Execution
from eztimer import EZTimer
timer = EZTimer()
timer.start()
# Your code to benchmark
result = sum(i*i for i in range(1000000))
elapsed = timer.get_elapsed_time()
print(f"Computation took {elapsed:.4f} seconds")
Timing with Pauses
from eztimer import EZTimer
import time
timer = EZTimer()
timer.start()
# First operation
time.sleep(0.5)
timer.pause()
# User interaction (not timed)
input("Press Enter to continue...")
timer.resume()
# Second operation
time.sleep(0.3)
print(f"Active time: {timer.get_elapsed_time():.2f} seconds")
## License
MIT
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
py_eztimer-1.0.0.tar.gz
(3.4 kB
view details)
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 py_eztimer-1.0.0.tar.gz.
File metadata
- Download URL: py_eztimer-1.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
263693691554c204dcd58ac1fb3c0ba40bfa398915af702cf3f0459be5d53de5
|
|
| MD5 |
3cd3775bb4c33d45808944778dcbd3a2
|
|
| BLAKE2b-256 |
27cc3abba1e924a2093f123ba9dd57385535bcfe0a99df84eaf5a762496401d6
|
File details
Details for the file py_eztimer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: py_eztimer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f42882297cf1936398e46cc65d258553fde457b68b64e15df1590cabfbdc5255
|
|
| MD5 |
67371c12a925b1adeb46705dbacea0e2
|
|
| BLAKE2b-256 |
6adb71111a6164ad97605edd3044e69a229d7a3ef628741270dc69fede9a21df
|