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
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.1.tar.gz.
File metadata
- Download URL: py_eztimer-1.0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54f0583ad9ce1078a655e180eb52aa0b8639e2256d0ccde95148da047914af1b
|
|
| MD5 |
4904f07016afee2a7d6fbe9f7df97e47
|
|
| BLAKE2b-256 |
1fd82ff921ad9e7f4ad606cb6700d7b3e66982817e843b12e0f84be9261a39f9
|
File details
Details for the file py_eztimer-1.0.1-py3-none-any.whl.
File metadata
- Download URL: py_eztimer-1.0.1-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 |
360dc8dbc3d38d7852862b452308080d47a84ae3211cdbed7a97a94fed019aec
|
|
| MD5 |
95478bb3fdbafde6f793e6ec1bccbe45
|
|
| BLAKE2b-256 |
0dc492e00b031fbcc2099cb1d7ee56cbe39a9a5084e1b00df0d458d6f60bcef5
|