Skip to content

Instantly share code, notes, and snippets.

@azich
Created May 22, 2012 19:16
Show Gist options
  • Save azich/2771043 to your computer and use it in GitHub Desktop.
Save azich/2771043 to your computer and use it in GitHub Desktop.
Lightweight Python Stopwatch
import time
from sys import stdout
try:
start = time.time()
while True:
s = time.time() - start
d = int(s / 86400)
s -= d * 86400
h = int(s / 3600)
s -= h * 3600
m = int(s / 60)
s -= m * 60
stdout.write("\r%dd %02d:%02d:%05.2f" % (d, h, m, s))
stdout.flush()
time.sleep(0.01)
except:
stdout.write("\r\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment