I’ve got a function to return a platform-dependent timestamp with high precision. Now I’d like to subtract 5 seconds from such a timestamp and am looking for the smartest way to achieve this.
This is the function:
def get_time():
""" start timer """
if sys.platform == "win32":
return time.clock()
else:
return time.time()
You want to use
timeit.default_timer, which does exactly that (get the most precise timer for the current platform).To subtract 5 seconds, just subtract 5:
The time given is a float value representing seconds.