Skip to content

jin/stopwatch.py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stopwatch.py

A simple stopwatch for python, small, efficient and no dependencies

Install

pip install stopwatch.py

Usage

from stopwatch import Stopwatch

stopwatch = Stopwatch() # Stopwatch keeps running
# but really its just math with time.perf_counter() so there isn't really a task
# running in background

stopwatch.stop() # stop stopwatch, time freezes
stopwatch.start() # Start it again
stopwatch.reset() # reset it back to 0
stopwatch.restart() # reset and start again
stopwatch.running # wether stopwatch is running
stopwatch.duration # Get the duration
str(stopwatch) # Get the friendly duration string

Python2 Support?

No sorry, This module depends on time.perf_counter() which doesn't exist on Python2 it should be compatible with any python3+ versions, maybe even other python implementations if it implements time.perf_counter()

License

MIT

Credits

Originally written by dirigeants in this file i just looked at it and rewrote it in python, and it felt useful to put it in a module.

About

A simple stopwatch for python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%