py-stopwatch
Stopwatch class for timing portions of python code.
- Free software: MIT license
- Documentation: https://py-stopwatch.readthedocs.io.
Features
- Tick-based stopwatch
- Support for Pause/Resume
- Support for multiple named-ticks
- Utility functions for time between different ticks
- No third party requirements.
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
…