summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-06-08 08:17:44 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-06-08 08:17:44 (GMT)
commitf30d60edbc0d5047a2fdd01e25868e4b814107e2 (patch)
tree426daf743461139871a9c8b79aa8f63b5f79ccf6 /Python/sysmodule.c
parentd68d3ee3dd504661a6f5b0f5810211fef814b919 (diff)
downloadcpython-f30d60edbc0d5047a2fdd01e25868e4b814107e2.zip
cpython-f30d60edbc0d5047a2fdd01e25868e4b814107e2.tar.gz
cpython-f30d60edbc0d5047a2fdd01e25868e4b814107e2.tar.bz2
Patch #510695: Add TSC profiling for the VM.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 09e411e..55c0425 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -442,6 +442,33 @@ PyDoc_STRVAR(getcheckinterval_doc,
"getcheckinterval() -> current check interval; see setcheckinterval()."
);
+#ifdef WITH_TSC
+static PyObject *
+sys_settscdump(PyObject *self, PyObject *args)
+{
+ int bool;
+ PyThreadState *tstate = PyThreadState_Get();
+
+ if (!PyArg_ParseTuple(args, "i:settscdump", &bool))
+ return NULL;
+ if (bool)
+ tstate->interp->tscdump = 1;
+ else
+ tstate->interp->tscdump = 0;
+ Py_INCREF(Py_None);
+ return Py_None;
+
+}
+
+PyDoc_STRVAR(settscdump_doc,
+"settscdump(bool)\n\
+\n\
+If true, tell the Python interpreter to dump VM measurements to\n\
+stderr. If false, turn off dump. The measurements are based on the\n\
+Pentium time-stamp counter."
+);
+#endif TSC
+
static PyObject *
sys_setrecursionlimit(PyObject *self, PyObject *args)
{
@@ -743,6 +770,9 @@ static PyMethodDef sys_methods[] = {
{"setprofile", sys_setprofile, METH_O, setprofile_doc},
{"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS,
setrecursionlimit_doc},
+#ifdef WITH_TSC
+ {"settscdump", sys_settscdump, METH_VARARGS, settscdump_doc},
+#endif
{"settrace", sys_settrace, METH_O, settrace_doc},
{"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc},
{NULL, NULL} /* sentinel */