[pypy-commit] pypy default: finally made the timing work under windows, which is probably a fake QPC

ctismer noreply at buildbot.pypy.org
Sun Mar 18 16:32:18 CET 2012


Author: Christian Tismer <tismer at stackless.com>
Branch: 
Changeset: r53790:aaffe3362a4b
Date: 2012-03-18 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/aaffe3362a4b/

Log:	finally made the timing work under windows, which is probably a fake
	QPC

diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -1496,13 +1496,30 @@
                                                c_nest, c_nest], 'void')
 
     def test_read_timestamp(self):
+        if sys.platform == 'win32':
+            # windows quite often is very inexact (like the old 8259 PIC),
+            # so we stretch the time a little bit.
+            # On my virtual Parallels machine in a 2GhZ Core i7 Mac Mini,
+            # the test starts working at delay == 21670 and stops at 20600000.
+            # We take the geometric mean value.
+            from math import log, exp
+            delay_min = 21670
+            delay_max = 20600000
+            delay = int(exp((log(delay_min)+log(delay_max))/2))
+            def wait_a_bit():
+                for i in xrange(delay): pass
+        else:
+            def wait_a_bit():
+                pass
         if longlong.is_64_bit:
             got1 = self.execute_operation(rop.READ_TIMESTAMP, [], 'int')
+            wait_a_bit()
             got2 = self.execute_operation(rop.READ_TIMESTAMP, [], 'int')
             res1 = got1.getint()
             res2 = got2.getint()
         else:
             got1 = self.execute_operation(rop.READ_TIMESTAMP, [], 'float')
+            wait_a_bit()
             got2 = self.execute_operation(rop.READ_TIMESTAMP, [], 'float')
             res1 = got1.getlonglong()
             res2 = got2.getlonglong()


More information about the pypy-commit mailing list