Python Stopwatch class for timing multiple portions of the code
Project description
py-stopwatch
Stopwatch class for timing your python code, with support for pause, resume and multiple named-ticks.
Free software: MIT license
Documentation: https://py-stopwatch.readthedocs.io.
Usage
from stopwatch import Stopwatch
t = Stopwatch()
t.start()
print("Started ..")
time.sleep(0.24)
print(f"t.tick(): {t.tick():.4f} seconds")
time.sleep(0.48)
print(f"t.tick(): {t.tick():.4f} seconds")
time.sleep(0.16)
print(f"t.tick('Named Tick-1'): {t.tick('Named Tick-1'):.4f} seconds")
t.pause()
print("Paused ..")
time.sleep(0.12)
t.resume()
print("Resumed ..")
print(f"t.last(): {t.last():.4f} seconds")
time.sleep(0.12)
print(f"t.tick(): {t.tick():.4f} seconds")
time.sleep(0.12)
print(f"t.tick('Named Tick-2'): {t.tick('Named Tick-2'):.4f} seconds")
t.stop()
print("Timer stopped.")
print("---")
print(f"Total pause: {t.time_paused:.2f} seconds.")
print(f"Total runtime: {t.time_active:.2f} seconds.")
print(f"Total time: {t.time_total:.2f} seconds.")
tij = t.time_elapsed(start_name='Named Tick-1', end_name='Named Tick-2')
print(f"Time between 'Named Tick-1' and 'Named Tick-2': {tij:.4f}")
Features
Tick-based stopwatch
Pause, Resume, Tick
Multiple named-ticks
Utility functions for time between different ticks
History
0.0.1 (2021-04-13)
First release on PyPI.
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
py-stopwatch-0.0.2.tar.gz
(12.2 kB
view hashes)
Built Distribution
Close
Hashes for py_stopwatch-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7edb4b013059a24baff73f1880fbdc754fdf684d844ae351c0d9e66a8ddc61a |
|
MD5 | 5c1a73323af29e292fffd45e88e2f6d0 |
|
BLAKE2b-256 | 2d5c02be7e0d28c294620c4038fb234624c4abe6bd4327e4a051a59d82edc2e3 |