From e76930f30355b52bc282955c11dde7d2ad0faeff Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Thu, 30 Sep 2021 00:54:20 +0900 Subject: [PATCH] ceval_warmup for windows --- Lib/test/libregrtest/pgo.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lib/test/libregrtest/pgo.py b/Lib/test/libregrtest/pgo.py index 582e812e284cc9..555f4ec3cf80f8 100644 --- a/Lib/test/libregrtest/pgo.py +++ b/Lib/test/libregrtest/pgo.py @@ -50,7 +50,30 @@ 'test_xml_etree_c', ] +def ceval_warmup(): + # MSVC needs additional ceval-loop counts for better performance. + import sys + if sys.platform != 'win32': + return + + def noop_trace(frame, event, arg): + return noop_trace + + print("warmup for tests on Windows...") + old_trace = sys.gettrace() + sys.settrace(noop_trace) + try: + jobcnt = len(PGO_TESTS) + for j in range(1, 1 + jobcnt): + print(f'{j}/{jobcnt}') + for i in range(800000): + pass + finally: + sys.settrace(old_trace) + + def setup_pgo_tests(ns): + ceval_warmup() if not ns.args and not ns.pgo_extended: # run default set of tests for PGO training ns.args = PGO_TESTS[:]