diff Python/sysmodule.c @ 32301:41c59d80bbc5 legacy-trunk

Patch #510695: Add TSC profiling for the VM.
author Martin v. Löwis <martin@v.loewis.de>
date Tue, 08 Jun 2004 08:17:44 +0000
parents 846b3ee7e106
children 748129e6e108
line wrap: on
line diff
--- a/Python/sysmodule.c	Tue Jun 08 02:58:50 2004 +0000
+++ b/Python/sysmodule.c	Tue Jun 08 08:17:44 2004 +0000
@@ -442,6 +442,33 @@
 "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 @@
 	{"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 */