Bug 1638990: [taskgraph] Use `time.monotonic` for bugbug timing when avaiable; r=ahal

In any case, `time.time` is preferable to `time.clock` when `time.monotonic` is
not available.

Differential Revision: https://phabricator.services.mozilla.com/D84082
This commit is contained in:
Tom Prince 2020-07-20 19:27:32 +00:00
Родитель 6d3ff10755
Коммит 732240dc4a
1 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -14,6 +14,12 @@ from mozbuild.util import memoize
from taskgraph.util.taskcluster import requests_retry_session
try:
# TODO(py3): use time.monotonic()
from time import monotonic
except ImportError:
from time import time as monotonic
BUGBUG_BASE_URL = "https://bugbug.herokuapp.com"
RETRY_TIMEOUT = 8 * 60 # seconds
RETRY_INTERVAL = 10 # seconds
@ -71,8 +77,7 @@ def _write_perfherder_data(lower_is_better):
@memoize
def push_schedules(branch, rev):
url = BUGBUG_BASE_URL + '/push/{branch}/{rev}/schedules'.format(branch=branch, rev=rev)
# TODO(py3): use time.monotonic()
start = time.clock()
start = monotonic()
session = get_session()
attempts = RETRY_TIMEOUT / RETRY_INTERVAL
i = 0
@ -85,7 +90,7 @@ def push_schedules(branch, rev):
time.sleep(RETRY_INTERVAL)
i += 1
end = time.clock()
end = monotonic()
_write_perfherder_data(lower_is_better={
'bugbug_push_schedules_time': end-start,