1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
from timeit import default_timer
def Time():
"""Returns some representation of the current time.
This wrapper is meant to take advantage of a higher time
resolution when available. Thus, its return value should be
treated as an opaque object. It can be compared to the current
time with TimeSince().
"""
return default_timer()
def TimeSince(t):
"""Compares a value returned by Time() to the current time.
Returns:
the time since t, in fractional seconds.
"""
return default_timer() - t
def PowersOf(logbase, count, lower=0, include_zero=True):
"""Returns a list of count powers of logbase (from logbase**lower)."""
if not include_zero:
return [logbase**i for i in range(lower, count + lower)]
return [0] + [logbase**i for i in range(lower, count + lower)]
|