]> granicus.if.org Git - python/commitdiff
Making C profiling a configure option (at least temporarily)
authorNicholas Bastin <nick.bastin@gmail.com>
Tue, 22 Jun 2004 03:51:38 +0000 (03:51 +0000)
committerNicholas Bastin <nick.bastin@gmail.com>
Tue, 22 Jun 2004 03:51:38 +0000 (03:51 +0000)
Python/ceval.c
configure
configure.in
pyconfig.h.in

index 088c8814ed8423d0b2797c59334efde4f6a86ff5..d5493cc0c64cc6386025c1298a7603524b88dd81 100644 (file)
@@ -3502,15 +3502,23 @@ call_function(PyObject ***pp_stack, int oparg
                        PyCFunction meth = PyCFunction_GET_FUNCTION(func);
                        PyObject *self = PyCFunction_GET_SELF(func);
                        if (flags & METH_NOARGS && na == 0) {
+#ifdef WITH_C_PROF
                                BEGIN_C_TRACE
+#endif
                                x = (*meth)(self, NULL);
+#ifdef WITH_C_PROF
                                END_C_TRACE
+#endif
                        }
                        else if (flags & METH_O && na == 1) {
                                PyObject *arg = EXT_POP(*pp_stack);
+#ifdef WITH_C_PROF
                                BEGIN_C_TRACE
+#endif
                                x = (*meth)(self, arg);
+#ifdef WITH_C_PROF
                                END_C_TRACE
+#endif
                                Py_DECREF(arg);
                        }
                        else {
@@ -3521,7 +3529,9 @@ call_function(PyObject ***pp_stack, int oparg
                else {
                        PyObject *callargs;
                        callargs = load_args(pp_stack, na);
+#ifdef WITH_C_PROF
                        BEGIN_C_TRACE
+#endif
 #ifdef WITH_TSC
                        rdtscll(*pintr0);
 #endif
@@ -3529,7 +3539,9 @@ call_function(PyObject ***pp_stack, int oparg
 #ifdef WITH_TSC
                        rdtscll(*pintr1);
 #endif
+#ifdef WITH_C_PROF
                        END_C_TRACE
+#endif
                        Py_XDECREF(callargs);
                }
        } else {
index 444132d44bf8597d67e082c47afa67dc83f95d7e..0c0c443c3e46e630712abc547f3741062a78a37c 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.457 .
+# From configure.in Revision: 1.458 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.4.
 #
@@ -869,6 +869,7 @@ Optional Packages:
                           deprecated; use --with(out)-threads
   --with-pth              use GNU pth threading libraries
   --with(out)-doc-strings disable/enable documentation strings
+  --with-c-profiling      Enable profiling of builtins and C extension functions
   --with(out)-tsc         enable/disable timestamp counter profile
   --with(out)-pymalloc    disable/enable specialized mallocs
   --with-wctype-functions use wctype.h functions
 echo "$as_me:$LINENO: result: $with_doc_strings" >&5
 echo "${ECHO_T}$with_doc_strings" >&6
 
+# Check for C call profiling support
+echo "$as_me:$LINENO: checking for --with-c-profiling" >&5
+echo $ECHO_N "checking for --with-c-profiling... $ECHO_C" >&6
+
+# Check whether --with-c-profiling or --without-c-profiling was given.
+if test "${with_c_profiling+set}" = set; then
+  withval="$with_c_profiling"
+
+if test "$withval" != no
+then
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_C_PROF 1
+_ACEOF
+
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi;
+
 # Check for Python-specific malloc support
 echo "$as_me:$LINENO: checking for --with-tsc" >&5
 echo $ECHO_N "checking for --with-tsc... $ECHO_C" >&6
index 7e1387447a29ec9409e10a3d808a80b549ea9674..c766eb18912b804e2f481033821bf72d2933677e 100644 (file)
@@ -1946,6 +1946,19 @@ then
 fi
 AC_MSG_RESULT($with_doc_strings)
 
+# Check for C call profiling support
+AC_MSG_CHECKING(for --with-c-profiling)
+AC_ARG_WITH(c-profiling,
+[  --with-c-profiling      Enable profiling of builtins and C extension functions], [
+if test "$withval" != no
+then
+  AC_DEFINE(WITH_C_PROF, 1,
+    [Define to enable profile hooks for C extension functions and builtins])
+    AC_MSG_RESULT(yes)
+else AC_MSG_RESULT(no)
+fi],
+[AC_MSG_RESULT(no)])
+
 # Check for Python-specific malloc support
 AC_MSG_CHECKING(for --with-tsc)
 AC_ARG_WITH(tsc,
index 8cb0cffb78c3ff4d9b26fedec0659d3285ea4c46..e939c013c6967537918f5ab02f2f9389a24ebebc 100644 (file)
 /* Define if WINDOW in curses.h offers a field _flags. */
 #undef WINDOW_HAS_FLAGS
 
+/* Define to enable profile hooks for C extension functions and builtins */
+#undef WITH_C_PROF
+
 /* Define if you want documentation strings in extension modules */
 #undef WITH_DOC_STRINGS