summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 8a9a58479a..444042f82d 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1909,6 +1909,66 @@ sys_is_finalizing_impl(PyObject *module)
return PyBool_FromLong(_Py_IsFinalizing());
}
+#ifdef Py_STATS
+/*[clinic input]
+sys._stats_on
+
+Turns on stats gathering (stats gathering is on by default).
+[clinic start generated code]*/
+
+static PyObject *
+sys__stats_on_impl(PyObject *module)
+/*[clinic end generated code: output=aca53eafcbb4d9fe input=8ddc6df94e484f3a]*/
+{
+ _py_stats = &_py_stats_struct;
+ Py_RETURN_NONE;
+}
+
+/*[clinic input]
+sys._stats_off
+
+Turns off stats gathering (stats gathering is on by default).
+[clinic start generated code]*/
+
+static PyObject *
+sys__stats_off_impl(PyObject *module)
+/*[clinic end generated code: output=1534c1ee63812214 input=b3e50e71ecf29f66]*/
+{
+ _py_stats = NULL;
+ Py_RETURN_NONE;
+}
+
+/*[clinic input]
+sys._stats_clear
+
+Clears the stats.
+[clinic start generated code]*/
+
+static PyObject *
+sys__stats_clear_impl(PyObject *module)
+/*[clinic end generated code: output=fb65a2525ee50604 input=3e03f2654f44da96]*/
+{
+ _Py_StatsClear();
+ Py_RETURN_NONE;
+}
+
+/*[clinic input]
+sys._stats_dump
+
+Dump stats to file, and clears the stats.
+[clinic start generated code]*/
+
+static PyObject *
+sys__stats_dump_impl(PyObject *module)
+/*[clinic end generated code: output=79f796fb2b4ddf05 input=92346f16d64f6f95]*/
+{
+ _Py_PrintSpecializationStats(1);
+ _Py_StatsClear();
+ Py_RETURN_NONE;
+}
+
+#endif
+
#ifdef ANDROID_API_LEVEL
/*[clinic input]
sys.getandroidapilevel
@@ -1978,6 +2038,12 @@ static PyMethodDef sys_methods[] = {
SYS_GET_ASYNCGEN_HOOKS_METHODDEF
SYS_GETANDROIDAPILEVEL_METHODDEF
SYS_UNRAISABLEHOOK_METHODDEF
+#ifdef Py_STATS
+ SYS__STATS_ON_METHODDEF
+ SYS__STATS_OFF_METHODDEF
+ SYS__STATS_CLEAR_METHODDEF
+ SYS__STATS_DUMP_METHODDEF
+#endif
{NULL, NULL} // sentinel
};