stopywatch
Python 3 Simple Stopwatch
This is a simple stopwatch that can be used in Python code to profile the duration of scripts,
Table of Contents
- Requirements
- Classes / Objects
- Functions
- Samples
1. Requirements
This package leverages datetime, which is a standard Python package
2. Classes
Stopwatch
This is the main and only class of the package.
Attributes
_days
Number of days since the Stopwatch instance was started until it was stopped (if it was stopped)
_hours
Number of hours since the Stopwatch instance was started until it was stopped (if it was stopped)
_minutes
Number of minutes since the Stopwatch instance was started until it was stopped (if it was stopped)
_seconds
Number of seconds since the Stopwatch instance was started until it was stopped (if it was stopped)
_microseconds
Number of microseconds since the Stopwatch instance was started until it was stopped (if it was stopped)
_total_seconds
Total seconds since the Stopwatch instance was started until it was stopped (if it was stopped)
_started
True if the Stopwatch is running, False otherwise
_stopped
True if the Stopwatch is not running, False otherwise
_flags
List of "times" when the Stopwatch was "paused", includes the stop time as well
Methods
start
Starts the Stopwatch
pause
Takes the current timestamp and creates a flag
stop
Stops the Stopwatch and creates a flag with the current timestamp
reset
Re-initializes the Stopwatch as if the instance was just created
is_started
Returns True if the Stopwatch is running, False otherwise
is_stopped
Returns True if the Stopwatch is NOT running, False otherwise
print_flags
Prints all flags to console in dd:hh:mm:ss.s format
get_elapsed_time
Returns a string with elapsed time with the format dd-hh-mm-ss.s
_calculate_delta
Calculates the timedelta from the start_stamp to the current datetime or a datetime passed as the stamp argument
_calculate_all_units
Caculates each of the timestamp-related attributes days, hours, minutes, etc---
Sample Code
from stopywatch import Stopwatch
from datetime import datetime
from time import sleep
timer = Stopwatch()
timer.start()
sleep(1)
timer.pause()
sleep(1)
timer.pause()
sleep(1)
timer.pause()
sleep(1)
timer.pause()
sleep(1)
timer.pause()
sleep(1)
print(timer.get_start_stamp())
print(timer.get_stop_stamp())
timer.stop()
timer.print_flags()
Metadata
Release files for stopywatch 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stopywatch-1.0.2.tar.gz | 4.2 kB | Without provenance | Details for stopywatch-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stopywatch-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for stopywatch-1.0.2-py3-none-any.whl |
Total release size: 8.9 kB
Release files / stopywatch-1.0.2.tar.gz
| Download URL | stopywatch-1.0.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63784c900d6ef1c806b56d0c63a57cea277dd214592377b7bc693412697b5d9f
|
|
BLAKE2b-256 checksum How to use checksums |
a7bb2ee32d9a98a9b6ab9f3cf9133aeec50c21ae4be940a0ab089307f64a5f99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Release files / stopywatch-1.0.2-py3-none-any.whl
| Download URL | stopywatch-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
589d39324fcfea37d635408cd2b9d07a574c91d28bf415b882a06ed8823b978d
|
|
BLAKE2b-256 checksum How to use checksums |
40b8b79958c0d0455f023d88a444ac449fed444afab5e1259891a333b1384a54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Security for stopywatch 1.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.