mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
Add some GC stats to Py_STATS (GH-107581)
This commit is contained in:
parent
fa45958450
commit
2ba7c7f7b1
5 changed files with 80 additions and 1 deletions
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
|
||||
#ifdef Py_STATS
|
||||
PyStats _py_stats_struct = { 0 };
|
||||
GCStats _py_gc_stats[NUM_GENERATIONS] = { 0 };
|
||||
PyStats _py_stats_struct = { .gc_stats = &_py_gc_stats[0] };
|
||||
PyStats *_py_stats = NULL;
|
||||
|
||||
#define ADD_STAT_TO_DICT(res, field) \
|
||||
|
@ -202,17 +203,32 @@ print_object_stats(FILE *out, ObjectStats *stats)
|
|||
fprintf(out, "Optimization uops executed: %" PRIu64 "\n", stats->optimization_uops_executed);
|
||||
}
|
||||
|
||||
static void
|
||||
print_gc_stats(FILE *out, GCStats *stats)
|
||||
{
|
||||
for (int i = 0; i < NUM_GENERATIONS; i++) {
|
||||
fprintf(out, "GC[%d] collections: %" PRIu64 "\n", i, stats[i].collections);
|
||||
fprintf(out, "GC[%d] object visits: %" PRIu64 "\n", i, stats[i].object_visits);
|
||||
fprintf(out, "GC[%d] objects collected: %" PRIu64 "\n", i, stats[i].objects_collected);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_stats(FILE *out, PyStats *stats) {
|
||||
print_spec_stats(out, stats->opcode_stats);
|
||||
print_call_stats(out, &stats->call_stats);
|
||||
print_object_stats(out, &stats->object_stats);
|
||||
print_gc_stats(out, stats->gc_stats);
|
||||
}
|
||||
|
||||
void
|
||||
_Py_StatsClear(void)
|
||||
{
|
||||
for (int i = 0; i < NUM_GENERATIONS; i++) {
|
||||
_py_gc_stats[i] = (GCStats) { 0 };
|
||||
}
|
||||
_py_stats_struct = (PyStats) { 0 };
|
||||
_py_stats_struct.gc_stats = _py_gc_stats;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue