A simple library to measure code performance.
Project description
Python-StopWatch-2
A simple stopwatch for measuring code performance. This is a fork from python-stopwatch, which adds static typing and a few other things.
→ USAGE ←
☍ INSTALLATION
To install the library, you can just run the following command:
poetry add python-stopwatch2
Or, using pip:
pip install python-stopwatch2
☍ BASIC USAGE
ƒ stopwatch.Stopwatch
You can use the start() and stop() methods to starts or stops the stopwatch counter.
from time import sleep
from stopwatch import Stopwatch
my_stopwatch = Stopwatch()
sleep(2)
my_stopwatch.stop()
print(my_stopwatch.elapsed) # 2.0
sleep(1)
print(my_stopwatch.elapsed) # 2.0
my_stopwatch.start()
sleep(1)
my_stopwatch.stop()
print(my_stopwatch.elapsed) # 3.0
print(f'Time elapsed: {my_stopwatch}') # Time elapsed: 3.00s
It is also possible to use Stopwatch with the with statement.
from time import sleep
from stopwatch import Stopwatch
with Stopwatch() as my_stopwatch:
sleep(3)
print(my_stopwatch.elapsed) # 3.0
print(f'Time elapsed: {my_stopwatch}') # Time elapsed: 3.00s
☍ DOCUMENTATION
To check out the docs, visit https://stopwatch2.vercel.app/
☍ CHANGELOG
Detailed changes for each release are documented in the CHANGELOG.md.
CONTRIBUTING
Pull requests are welcome!
☍ 📑 LICENSE
Copyright (c) 2021-2022 Jonghwan Hyeon, 2022-present Rafael
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
Hashes for python_stopwatch2-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c32e12867e740eef36831f63ede7a7b4652c1bf19d9e88ccba075367a463f25b |
|
MD5 | 72ba984721360537129d1686b12203d5 |
|
BLAKE2b-256 | 713c2f17ae1751773306f215779d608996ae0ff2a8d87d617495123d96ad2b2d |