Skip to content

Commit

Permalink
pythongh-88494: Reduce CLOCK_RES to 1 ms in tests
Browse files Browse the repository at this point in the history
On Windows, time.monotonic() now calls QueryPerformanceCounter()
which has a resolution of 100 ns. Reduce CLOCK_RES from 50 or 100 ms
to 1 ms.
  • Loading branch information
vstinner committed Apr 29, 2024
1 parent 23d0371 commit be949bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
raise unittest.SkipTest("libasan has a pthread_create() dead lock related to thread+fork")


# gh-110666: Tolerate a difference of 100 ms when comparing timings
# gh-110666: Tolerate a difference of 1 ms when comparing timings
# (clock resolution)
CLOCK_RES = 0.100
CLOCK_RES = 0.001


def latin(s):
Expand Down
6 changes: 2 additions & 4 deletions Lib/test/test_asyncio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
from test.support import threading_helper


# Use the maximum known clock resolution (gh-75191, gh-110088): Windows
# GetTickCount64() has a resolution of 15.6 ms. Use 50 ms to tolerate rounding
# issues.
CLOCK_RES = 0.050
# Tolerate 1 ms difference when comparing timings.
CLOCK_RES = 0.001


def data_file(*filename):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
SEC_TO_NS = 10 ** 9
DAY_TO_SEC = (24 * 60 * 60)
# Worst clock resolution: maximum delta between two clock reads.
CLOCK_RES = 0.050
CLOCK_RES = 0.001


class CAPITest(unittest.TestCase):
Expand Down

0 comments on commit be949bb

Please sign in to comment.