Skip to content

Commit 035a222

Browse files
committed
dump profiles separately only if enabled by env var
1 parent 0696173 commit 035a222

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

benchmark/benchmark.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function runValgrindPhpCgiCommand(
110110
}
111111

112112
$process = runCommand([
113+
'BENCHMARK_DUMP_SEPARATE_PROFILES=1',
113114
'valgrind',
114115
'--tool=callgrind',
115116
'--dump-instr=yes',

sapi/cgi/cgi_main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,16 @@ PHP_FUNCTION(apache_response_headers) /* {{{ */
16961696
}
16971697
/* }}} */
16981698

1699+
#ifdef HAVE_VALGRIND
1700+
static inline void callgrind_dump_stats(void)
1701+
{
1702+
char *tmp = getenv("BENCHMARK_DUMP_SEPARATE_PROFILES");
1703+
if (tmp && ZEND_ATOL(tmp)) {
1704+
CALLGRIND_DUMP_STATS;
1705+
}
1706+
}
1707+
#endif
1708+
16991709
static zend_module_entry cgi_module_entry = {
17001710
STANDARD_MODULE_HEADER,
17011711
"cgi-fcgi",
@@ -2260,7 +2270,7 @@ consult the installation file that came with this distribution, or visit \n\
22602270
#ifdef HAVE_VALGRIND
22612271
if (benchmark) {
22622272
/* measure startup and each benchmark run separately */
2263-
CALLGRIND_DUMP_STATS;
2273+
callgrind_dump_stats();
22642274
}
22652275
#endif
22662276

@@ -2578,7 +2588,7 @@ consult the installation file that came with this distribution, or visit \n\
25782588

25792589
#ifdef HAVE_VALGRIND
25802590
/* measure shutdown separately */
2581-
CALLGRIND_DUMP_STATS;
2591+
callgrind_dump_stats();
25822592
#endif
25832593

25842594
break;

0 commit comments

Comments
 (0)