Skip to main content

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.

→ STATUS ←

Pypi Version Python Versions Repo Size License Stars Contributors

→ 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

MIT

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

python-stopwatch2-1.1.0.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

python_stopwatch2-1.1.0-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page