mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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.
This commit is contained in:
parent
98d2827002
commit
54957f16a6
1 changed files with 2 additions and 2 deletions
|
@ -1211,7 +1211,7 @@ gc_collect_main(PyThreadState *tstate, int generation,
|
||||||
if (gcstate->debug & DEBUG_STATS) {
|
if (gcstate->debug & DEBUG_STATS) {
|
||||||
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
|
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
|
||||||
show_stats_each_generations(gcstate);
|
show_stats_each_generations(gcstate);
|
||||||
t1 = _PyTime_GetMonotonicClock();
|
t1 = _PyTime_GetPerfCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyDTrace_GC_START_ENABLED())
|
if (PyDTrace_GC_START_ENABLED())
|
||||||
|
@ -1307,7 +1307,7 @@ gc_collect_main(PyThreadState *tstate, int generation,
|
||||||
debug_cycle("uncollectable", FROM_GC(gc));
|
debug_cycle("uncollectable", FROM_GC(gc));
|
||||||
}
|
}
|
||||||
if (gcstate->debug & DEBUG_STATS) {
|
if (gcstate->debug & DEBUG_STATS) {
|
||||||
double d = _PyTime_AsSecondsDouble(_PyTime_GetMonotonicClock() - t1);
|
double d = _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter() - t1);
|
||||||
PySys_WriteStderr(
|
PySys_WriteStderr(
|
||||||
"gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
|
"gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
|
||||||
n+m, n, d);
|
n+m, n, d);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue