diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-04-29 23:39:57 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-04-29 23:39:57 (GMT) |
commit | 9a8ad0c5ea6d9562d94d6e4f8c0be28927cdcaa6 (patch) | |
tree | b3392e89a7f5fc6e69a5f11e6017ca55a5c540b1 /Lib/test | |
parent | 5df72c2c27b8a4ff05201eb613d30b50f69c7869 (diff) | |
download | cpython-9a8ad0c5ea6d9562d94d6e4f8c0be28927cdcaa6.zip cpython-9a8ad0c5ea6d9562d94d6e4f8c0be28927cdcaa6.tar.gz cpython-9a8ad0c5ea6d9562d94d6e4f8c0be28927cdcaa6.tar.bz2 |
Issue #14428: Remove test_process_time_threads() from test_time
The test is unstable and it's not really interesting to test exactly how
threads are handled.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_time.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 435e0a4..06047cf 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -389,58 +389,6 @@ class TimeTestCase(unittest.TestCase): self.assertEqual(info.is_monotonic, True) self.assertEqual(info.is_adjusted, False) - @unittest.skipUnless(threading, - 'need threading') - def test_process_time_threads(self): - def factorial(n): - if n >= 2: - return n * factorial(n-1) - else: - return 1 - - def use_cpu(n, loops): - for loop in range(loops): - factorial(n) - - class FactorialThread(threading.Thread): - def __init__(self, n, loops): - threading.Thread.__init__(self) - self.n = n - self.loops = loops - - def run(self): - use_cpu(self.n, self.loops) - - # Calibrate use_cpu() to use at least 1 ms of system time - n = 50 - loops = 1 - resolution = time.get_clock_info('process_time').resolution - min_rdt = max(resolution, 0.001) - while 1: - rt1 = time.time() - t1 = time.process_time() - use_cpu(n, loops) - t2 = time.process_time() - rt2 = time.time() - rdt = rt2 - rt1 - if rdt >= min_rdt: - break - loops *= 2 - busy = t2 - t1 - - # Ensure that time.process_time() includes the CPU time of all threads - thread = FactorialThread(n, loops) - t1 = time.process_time() - thread.start() - # Use sleep() instead of thread.join() because thread.join() time may - # be included in time.process_time() depending on its implementation - time.sleep(rdt * 2) - t2 = time.process_time() - thread.stop = True - thread.join() - # Use a factor of 0.75 because time.process_time() is maybe not precise - self.assertGreaterEqual(t2 - t1, busy * 0.75) - @unittest.skipUnless(hasattr(time, 'monotonic'), 'need time.monotonic') @unittest.skipUnless(hasattr(time, 'clock_settime'), |