| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
""" There is the possibility that time.clock be non monotonic in multicore hardware, |
| 7 |
due to the underlying use of win32 QueryPerformanceCounter. |
| 8 |
If your update is seeing a negative dt, then time.clock is probably the culprit. |
| 9 |
AMD or Intel Patches for multicore may fix this problem (if you see it at all)""" |
| 10 |
import time |
| 11 |
import sys |
| 12 |
from tests.annotations import require_platform, Platform |
| 13 |
import unittest |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
if sys.version_info[:2] < (3, 5): |
| 18 |
clock = time.clock |
| 19 |
else: |
| 20 |
clock = time.perf_counter |
| 21 |
|
| 22 |
|
| 23 |
@require_platform(Platform.WINDOWS) |
| 24 |
class WindowsMulticoreClockTestCase(unittest.TestCase): |
| 25 |
def test_multicore(self): |
| 26 |
failures = 0 |
| 27 |
old_time = clock() |
| 28 |
end_time = time.time() + 3 |
| 29 |
while time.time() < end_time: |
| 30 |
t = clock() |
| 31 |
if t < old_time: |
| 32 |
failures += 1 |
| 33 |
old_time = t |
| 34 |
time.sleep(0.001) |
| 35 |
self.assertTrue(failures == 0) |