A precise and lightweight stopwatch built on top of `perf_counter`, which can be used as a replacement for `perf_counter` that returns absolute time starting from zero.
Project description
stoppy ⏱
A precise and lightweight stopwatch built on top of perf_counter, which can be used as a replacement for perf_counter that returns absolute time starting from zero.
The stopwatch can optionally be started automatically by calling time(True) instead of start(), which can streamline usage when polling the time repeatedly.
Installation
Install from PyPI via:
pip install stoppy
Usage
Basic usage is as follows:
from time import sleep
from stoppy import Stopwatch
with Stopwatch(start=True) as stopwatch:
sleep(0.1)
stopwatch.stop()
print(stopwatch.time())
stopwatch.reset()
It can also be used as a direct replacement for perf_counter that returns absolute time starting from zero:
from stoppy import Stopwatch
with Stopwatch() as stopwatch:
# Calling `stopwatch.time(True)` is equivalent to calling `perf_counter()`, but starts from exactly zero
print(stopwatch.time(True))
For all usage examples see examples/.
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 stoppy-1.0.5.tar.gz.
File metadata
- Download URL: stoppy-1.0.5.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e113e7f7369c969108cc925d3ed5e247196c1a0f633b35ca6887886d40261a19
|
|
| MD5 |
36d1618392b8c385c4990cd1801b9a61
|
|
| BLAKE2b-256 |
5d9e57e189186bb267dd7c36e68e5a00874879d3569df32361eea0f0cd1c1456
|
File details
Details for the file stoppy-1.0.5-py3-none-any.whl.
File metadata
- Download URL: stoppy-1.0.5-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
917b7ddb5c238d095e36570d458cbe1d6655adb1332782d6f90d4c415f3aba28
|
|
| MD5 |
a1484239567c4c18cf2f0e62652dfee2
|
|
| BLAKE2b-256 |
d181ee00d9a480bee912db48460e78dcff97e534d007d9174862d44d6c341532
|