Skip to content

Commit dc2f12e

Browse files
committed
Add cachegrind support for php-cgi warmups
Cachegrind supports cg_annotate --diff, which makes it much easier to compare the performance of two patches.
1 parent 5586d0c commit dc2f12e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ AS_VAR_IF([PHP_VALGRIND], [no],,
751751
AC_DEFINE([HAVE_VALGRIND], [1],
752752
[Define to 1 if Valgrind is enabled and supported.])])])
753753

754+
if test "$PHP_VALGRIND" = "yes"; then
755+
AC_CHECK_HEADERS([valgrind/cachegrind.h])
756+
fi
757+
754758
dnl General settings.
755759
dnl ----------------------------------------------------------------------------
756760
PHP_CONFIGURE_PART(General settings)

sapi/cgi/cgi_main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
9393

9494
#ifdef HAVE_VALGRIND
9595
# include "valgrind/callgrind.h"
96+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
97+
# include "valgrind/cachegrind.h"
98+
# endif
9699
#endif
97100

98101
#ifndef PHP_WIN32
@@ -2249,6 +2252,10 @@ consult the installation file that came with this distribution, or visit \n\
22492252
CALLGRIND_STOP_INSTRUMENTATION;
22502253
/* We're not interested in measuring startup */
22512254
CALLGRIND_ZERO_STATS;
2255+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
2256+
CACHEGRIND_STOP_INSTRUMENTATION;
2257+
/* Zeroing stats is not supported for cachegrind. */
2258+
# endif
22522259
}
22532260
#endif
22542261
} else {
@@ -2461,6 +2468,9 @@ consult the installation file that came with this distribution, or visit \n\
24612468
#ifdef HAVE_VALGRIND
24622469
if (warmup_repeats == 0) {
24632470
CALLGRIND_START_INSTRUMENTATION;
2471+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
2472+
CACHEGRIND_START_INSTRUMENTATION;
2473+
# endif
24642474
}
24652475
#endif
24662476

@@ -2585,6 +2595,9 @@ consult the installation file that came with this distribution, or visit \n\
25852595
#ifdef HAVE_VALGRIND
25862596
/* We're not interested in measuring shutdown */
25872597
CALLGRIND_STOP_INSTRUMENTATION;
2598+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
2599+
CACHEGRIND_STOP_INSTRUMENTATION;
2600+
# endif
25882601
#endif
25892602

25902603
if (!fastcgi) {

0 commit comments

Comments
 (0)