https://github.com/ravener/stopwatch.py
A simple stopwatch for python
https://github.com/ravener/stopwatch.py
python stopwatch
Last synced: 10 months ago
JSON representation
A simple stopwatch for python
- Host: GitHub
- URL: https://github.com/ravener/stopwatch.py
- Owner: ravener
- License: mit
- Created: 2018-09-07T13:18:14.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-02-20T14:26:41.000Z (almost 2 years ago)
- Last Synced: 2025-02-27T14:48:00.728Z (11 months ago)
- Topics: python, stopwatch
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 24
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Stopwatch.py
============
A simple stopwatch for Python.
Install
-------
Requires Python 3.5+
.. code:: sh
pip install stopwatch.py
Usage
-----
.. code:: py
from stopwatch import Stopwatch
# Argument specifies decimal precision for __str__
# e.g 2 digits = 1.00, 3 digits = 1.000
# Optional, defaults to 2
stopwatch = Stopwatch(2) # Start a stopwatch
# It's just math with time.perf_counter() so there isn't really a task
# running in background
stopwatch.stop() # Stop stopwatch, time freezes
stopwatch.start() # Start it again
stopwatch.reset() # Reset it back to 0
stopwatch.restart() # Reset and start again
stopwatch.running # Whether stopwatch is running
stopwatch.duration # Get the duration (in seconds)
str(stopwatch) # Get a friendly duration string
License
-------
MIT