[Python-checkins] r45590 - python/trunk/Modules/gcmodule.c (original) (raw)

skip.montanaro python-checkins at python.org
Fri Apr 21 03:33:41 CEST 2006


Author: skip.montanaro Date: Fri Apr 21 03:33:40 2006 New Revision: 45590

Modified: python/trunk/Modules/gcmodule.c Log: This is a long-ago patch I submitted to SF (1100924) to time the gc passes. Barry approved it awhile ago. Been sitting in my sandbox for awhile as well.

Modified: python/trunk/Modules/gcmodule.c

--- python/trunk/Modules/gcmodule.c (original) +++ python/trunk/Modules/gcmodule.c Fri Apr 21 03:33:40 2006 @@ -734,6 +734,8 @@ PyGC_Head unreachable; /* non-problematic unreachable trash / PyGC_Head finalizers; / objects with, & reachable from, del */ PyGC_Head *gc; + static PyObject *tmod = NULL; + double t1 = 0.0;

 if (delstr == NULL) {
     delstr = PyString_InternFromString("__del__");

@@ -741,7 +743,23 @@ Py_FatalError("gc couldn't allocate "__del__""); }

@@ -814,6 +832,17 @@ if (debug & DEBUG_COLLECTABLE) { debug_cycle("collectable", FROM_GC(gc)); } + if (tmod != NULL && (debug & DEBUG_STATS)) { + PyObject *f = PyObject_CallMethod(tmod, "time", NULL); + if (f == NULL) { + PyErr_Clear(); + } + else { + t1 = PyFloat_AsDouble(f)-t1; + Py_DECREF(f); + PySys_WriteStderr("gc: %.4fs elapsed.\n", t1); + } + } }

 /* Clear weakrefs and invoke callbacks as necessary. */


More information about the Python-checkins mailing list