]> granicus.if.org Git - php/commitdiff
Exclude warm-up requests from callgrind profile.
authorDmitry Stogov <dmitry@zend.com>
Wed, 31 May 2017 13:16:56 +0000 (16:16 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 31 May 2017 13:16:56 +0000 (16:16 +0300)
acinclude.m4
configure.ac
sapi/cgi/cgi_main.c

index bc0e792f4e09246d22e58a4e4d86222169c1333d..07ae363f6562b6c5ac3b02f1423e2ec990f2a747 100644 (file)
@@ -3224,3 +3224,23 @@ AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [
 
 dnl Load the AX_CHECK_COMPILE_FLAG macro from the autoconf archive.
 m4_include([build/ax_check_compile_flag.m4])
+
+dnl PHP_CHECK_VALGRIND
+AC_DEFUN([PHP_CHECK_VALGRIND], [
+  AC_MSG_CHECKING([for valgrind])
+
+  SEARCH_PATH="/usr/local /usr"
+  SEARCH_FOR="/include/valgrind/valgrind.h"
+  for i in $SEARCH_PATH ; do
+    if test -r $i/$SEARCH_FOR; then
+      VALGRIND_DIR=$i
+    fi
+  done
+
+  if test -z "$VALGRIND_DIR"; then
+    AC_MSG_RESULT([not found])
+  else
+    AC_MSG_RESULT(found in $VALGRIND_DIR)
+    AC_DEFINE(HAVE_VALGRIND, 1, [ ])
+  fi
+])
index 598418fd89cb2fdf04f545569e82069f2d7a1815..9937a4c15d8ebec59205c1f5e9056b18febf37e4 100644 (file)
@@ -751,6 +751,8 @@ if test "x$php_crypt_r" = "x1"; then
   PHP_CRYPT_R_STYLE
 fi
 
+PHP_CHECK_VALGRIND
+
 dnl General settings.
 dnl -------------------------------------------------------------------------
 PHP_CONFIGURE_PART(General settings)
index 2cf16449f995d72a5e194e2337741e20ee4ab590..8639027dbc321115a41c62467be02674e3e04aaf 100644 (file)
@@ -96,6 +96,10 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
 # include "openssl/applink.c"
 #endif
 
+#ifdef HAVE_VALGRIND
+# include "valgrind/callgrind.h"
+#endif
+
 #ifndef PHP_WIN32
 /* XXX this will need to change later when threaded fastcgi is implemented.  shane */
 struct sigaction act, old_term, old_quit, old_int;
@@ -2246,6 +2250,11 @@ consult the installation file that came with this distribution, or visit \n\
                                                if (comma) {
                                                        warmup_repeats = atoi(php_optarg);
                                                        repeats = atoi(comma + 1);
+#ifdef HAVE_VALGRIND
+                                                       if (warmup_repeats > 0) {
+                                                               CALLGRIND_STOP_INSTRUMENTATION;
+                                                       }
+#endif
                                                } else {
                                                        repeats = atoi(php_optarg);
                                                }
@@ -2667,6 +2676,9 @@ fastcgi_request_done:
                                                        gettimeofday(&start, NULL);
 #else
                                                        time(&start);
+#endif
+#ifdef HAVE_VALGRIND
+                                                       CALLGRIND_START_INSTRUMENTATION;
 #endif
                                                }
                                                continue;