From 1823f4d6422ba13afebcbafbd787a665fcf1ea05 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Jun 2016 06:44:09 +0530 Subject: [PATCH] Use a high resolution timer for timing tests --- src/calibre/utils/run_tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py index f5be1daa12..bea6201f35 100644 --- a/src/calibre/utils/run_tests.py +++ b/src/calibre/utils/run_tests.py @@ -4,7 +4,8 @@ from __future__ import (unicode_literals, division, absolute_import, print_function) -import unittest, functools, time, os, importlib +import unittest, functools, os, importlib +from calibre.utils.monotonic import monotonic def no_endl(f): @functools.wraps(f) @@ -29,14 +30,14 @@ class TestResult(unittest.TextTestResult): self.times = {} def startTest(self, test): - self.start_time[test] = time.time() + self.start_time[test] = monotonic() return super(TestResult, self).startTest(test) def stopTest(self, test): orig = self.stream.writeln self.stream.writeln = self.stream.write super(TestResult, self).stopTest(test) - elapsed = time.time() + elapsed = monotonic() elapsed -= self.start_time.get(test, elapsed) self.times[test] = elapsed self.stream.writeln = orig