8000 bpo-41710: gc_collect_main() uses _PyTime_GetPerfCounter() (GH-28676) · python/cpython@54957f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54957f1

Browse files
authored
bpo-41710: gc_collect_main() uses _PyTime_GetPerfCounter() (GH-28676)
If the DEBUG_STATS debug flag is set, gc_collect_main() now uses _PyTime_GetPerfCounter() instead of _PyTime_GetMonotonicClock() to measure the elapsed time. On Windows, _PyTime_GetMonotonicClock() only has a resolution of 15.6 ms, whereas _PyTime_GetPerfCounter() is closer to a resolution of 100 ns.
1 parent 98d2827 commit 54957f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Modules/gcmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ gc_collect_main(PyThreadState *tstate, int generation,
12111211
if (gcstate->debug & DEBUG_STATS) {
12121212
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
12131213
show_stats_each_generations(gcstate);
1214-
t1 = _PyTime_GetMonotonicClock();
1214+
t1 = _PyTime_GetPerfCounter();
12151215
}
12161216

12171217
if (PyDTrace_GC_START_ENABLED())
@@ -1307,7 +1307,7 @@ gc_collect_main(PyThreadState *tstate, int generation,
13071307
debug_cycle("uncollectable", FROM_GC(gc));
13081308
}
13091309
if (gcstate->debug & DEBUG_STATS) {
1310-
double d = _PyTime_AsSecondsDouble(_PyTime_GetMonotonicClock() - t1);
1310+
double d = _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter() - t1);
13111311
PySys_WriteStderr(
13121312
"gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
13131313
n+m, n, d);

0 commit comments

Comments
 (0)
0