summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-05-16 13:35:11 (GMT)
committerGitHub <noreply@github.com>2022-05-16 13:35:11 (GMT)
commitfa2b8b75eb2b8a0193d587e02b488a73579118fc (patch)
tree023f4ceed47906c30c68348c032a38707ec5516f /Python
parentf6fd8aac13714ce17650eb4a648d5c08f0be53b4 (diff)
downloadcpython-fa2b8b75eb2b8a0193d587e02b488a73579118fc.zip
cpython-fa2b8b75eb2b8a0193d587e02b488a73579118fc.tar.gz
cpython-fa2b8b75eb2b8a0193d587e02b488a73579118fc.tar.bz2
Improve object stats (#92845)
* Add incref/decref stats * Show ratios for allocation in summary
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c2
-rw-r--r--Python/specialize.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index c73218f..c81d0ef 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -55,6 +55,7 @@
#undef Py_DECREF
#define Py_DECREF(arg) \
do { \
+ _Py_DECREF_STAT_INC(); \
PyObject *op = _PyObject_CAST(arg); \
if (--op->ob_refcnt == 0) { \
destructor dealloc = Py_TYPE(op)->tp_dealloc; \
@@ -78,6 +79,7 @@
#undef _Py_DECREF_SPECIALIZED
#define _Py_DECREF_SPECIALIZED(arg, dealloc) \
do { \
+ _Py_DECREF_STAT_INC(); \
PyObject *op = _PyObject_CAST(arg); \
if (--op->ob_refcnt == 0) { \
destructor d = (destructor)(dealloc); \
diff --git a/Python/specialize.c b/Python/specialize.c
index fa42993..6a91389 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -191,6 +191,8 @@ print_object_stats(FILE *out, ObjectStats *stats)
fprintf(out, "Object allocations over 4 kbytes: %" PRIu64 "\n", stats->allocations_big);
fprintf(out, "Object frees: %" PRIu64 "\n", stats->frees);
fprintf(out, "Object new values: %" PRIu64 "\n", stats->new_values);
+ fprintf(out, "Object increfs: %" PRIu64 "\n", stats->increfs);
+ fprintf(out, "Object decrefs: %" PRIu64 "\n", stats->decrefs);
fprintf(out, "Object materialize dict (on request): %" PRIu64 "\n", stats->dict_materialized_on_request);
fprintf(out, "Object materialize dict (new key): %" PRIu64 "\n", stats->dict_materialized_new_key);
fprintf(out, "Object materialize dict (too big): %" PRIu64 "\n", stats->dict_materialized_too_big);