Bug 1624190 - Use time.process_time() on Python 3; r=rstewart

time.clock() is deprecated since Python 3.3 and gone in Python 3.8.

Depends on D67773

Differential Revision: https://phabricator.services.mozilla.com/D67774

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Anthony Ramine 2020-03-23 16:32:07 +00:00
Родитель 3806c4e3c2
Коммит 4bbeb892c3
2 изменённых файлов: 13 добавлений и 3 удалений

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

@ -21,13 +21,16 @@ from mozbuild.base import MachCommandConditions
from mozbuild.frontend.emitter import TreeMetadataEmitter
from mozbuild.frontend.reader import BuildReader
from mozbuild.mozinfo import write_mozinfo
from mozbuild.util import FileAvoidWrite
from itertools import chain
from mozbuild.backend import (
backends,
get_backend_class,
)
from mozbuild.util import (
FileAvoidWrite,
process_time,
)
log_manager = LoggingManager()
@ -117,7 +120,7 @@ def config_status(topobjdir='.', topsrcdir='.', defines=None,
with FileAvoidWrite(os.path.join(topobjdir, 'mozinfo.json')) as f:
write_mozinfo(f, env, os.environ)
cpu_start = time.clock()
cpu_start = process_time()
time_start = time.time()
# Make appropriate backend instances, defaulting to RecursiveMakeBackend,
@ -153,7 +156,7 @@ def config_status(topobjdir='.', topsrcdir='.', defines=None,
summary = obj.gyp_summary()
print(summary, file=sys.stderr)
cpu_time = time.clock() - cpu_start
cpu_time = process_time() - cpu_start
wall_time = time.time() - time_start
efficiency = cpu_time / wall_time if wall_time else 100
untracked = wall_time - execution_time

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

@ -1502,3 +1502,10 @@ def ensure_subprocess_env(env, encoding='utf-8'):
"""
ensure = ensure_bytes if sys.version_info[0] < 3 else ensure_unicode
return {ensure(k, encoding): ensure(v, encoding) for k, v in six.iteritems(env)}
def process_time():
if six.PY2:
return time.clock()
else:
return time.process_time()