Skip to content

Instantly share code, notes, and snippets.

@peace098beat
Created April 1, 2016 11:48
Show Gist options
  • Save peace098beat/7879b30d8d98e1a35a15b2b2826fa47f to your computer and use it in GitHub Desktop.
Save peace098beat/7879b30d8d98e1a35a15b2b2826fa47f to your computer and use it in GitHub Desktop.
[Python] StopWatch
# -*- coding: utf-8 -*-
"""
ptime.py - Precision time function made os-independent (should have been taken care of by python)
Copyright 2010 Luke Campagnola
Distributed under MIT/X11 license. See license.txt for more infomation.
from pyqtgraph.ptime import time
now = time()
dt = now - lastTime
"""
import sys
import time as systime
START_TIME = None
time = None
def winTime():
"""Return the current time in seconds with high precision (windows version, use Manager.time() to stay platform independent)."""
return systime.clock() + START_TIME
#return systime.time()
def unixTime():
"""Return the current time in seconds with high precision (unix version, use Manager.time() to stay platform independent)."""
return systime.time()
if sys.platform.startswith('win'):
cstart = systime.clock() ### Required to start the clock in windows
START_TIME = systime.time() - cstart
time = winTime
else:
time = unixTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment