From 1aa90883681fe6e864df776b029088c3b9302d7c Mon Sep 17 00:00:00 2001 From: Simon Chabot Date: Thu, 24 Oct 2019 14:55:49 +0200 Subject: Use time.process_time instead of time.clock (deprecated) time.clock is deprecated since python 3.3 and will be removed in python 3.8 this patch breaks backward compatibility with python < 3.3. --- logilab/common/decorators.py | 6 +++--- logilab/common/pytest.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/logilab/common/decorators.py b/logilab/common/decorators.py index 63504ad..9ec1b5f 100644 --- a/logilab/common/decorators.py +++ b/logilab/common/decorators.py @@ -23,7 +23,7 @@ __docformat__ = "restructuredtext en" import sys import types -from time import clock, time +from time import process_time, time from inspect import isgeneratorfunction import six @@ -232,10 +232,10 @@ class iclassmethod(object): def timed(f): def wrap(*args, **kwargs): t = time() - c = clock() + c = process_time() res = f(*args, **kwargs) print('%s clock: %.9f / time: %.9f' % (f.__name__, - clock() - c, time() - t)) + process_time() - c, time() - t)) return res return wrap diff --git a/logilab/common/pytest.py b/logilab/common/pytest.py index c644a61..5c62816 100644 --- a/logilab/common/pytest.py +++ b/logilab/common/pytest.py @@ -115,7 +115,7 @@ FILE_RESTART = ".pytest.restart" import os, sys, re import os.path as osp -from time import time, clock +from time import process_time, time import warnings import types import inspect @@ -385,7 +385,7 @@ class PyTester(object): print((' %s ' % osp.basename(filename)).center(70, '='), file=sys.__stderr__) try: - tstart, cstart = time(), clock() + tstart, cstart = time(), process_time() try: testprog = SkipAwareTestProgram(modname, batchmode=batchmode, cvg=self.cvg, options=self.options, outstream=sys.stderr) @@ -406,7 +406,7 @@ class PyTester(object): traceback.print_exc(file=sys.stderr) return None - tend, cend = time(), clock() + tend, cend = time(), process_time() ttime, ctime = (tend - tstart), (cend - cstart) self.report.feed(filename, testprog.result, ttime, ctime) return testprog @@ -515,10 +515,10 @@ class DjangoTester(PyTester): file=sys.stderr) try: try: - tstart, cstart = time(), clock() + tstart, cstart = time(), process_time() self.before_testfile() testprog = SkipAwareTestProgram(modname, batchmode=batchmode, cvg=self.cvg) - tend, cend = time(), clock() + tend, cend = time(), process_time() ttime, ctime = (tend - tstart), (cend - cstart) self.report.feed(filename, testprog.result, ttime, ctime) return testprog -- cgit v1.2.1