mirror of
https://github.com/quantum5/optimize-later.git
synced 2025-04-24 12:32:04 -04:00
Method for getting appropriate timer method
This commit is contained in:
parent
cdb265a97a
commit
9597a6066d
|
@ -11,8 +11,23 @@ from optimize_later.utils import NoArgDecoratorMeta, with_metaclass
|
|||
from optimize_later import utils
|
||||
|
||||
log = logging.getLogger(__name__.rpartition('.')[0] or __name__)
|
||||
timer = [time.time, time.clock][os.name == 'nt']
|
||||
|
||||
def _get_timer():
|
||||
"""
|
||||
Returns the approprite timer method
|
||||
for the current OS and version of Python
|
||||
"""
|
||||
options = [time.time,]
|
||||
try:
|
||||
options.append(time.clock)
|
||||
except AttributeError:
|
||||
# Expected to occur in Python 3.8 since time.clock is removed in this version of Python.
|
||||
options.append(time.process_time)
|
||||
|
||||
timer = options[os.name == 'nt']
|
||||
return timer
|
||||
|
||||
timer = _get_timer()
|
||||
|
||||
def _generate_default_name():
|
||||
for entry in inspect.stack():
|
||||
|
|
Loading…
Reference in a new issue