Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d77734

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

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

‎benchmark/benchmark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function runValgrindPhpCgiCommand(
125125
'-d opcache.jit_buffer_size=128M',
126126
'-d opcache.validate_timestamps=0',
127127
...$args,
128-
]);
128+
], null, array_merge(getenv(), ['BENCHMARK_DUMP_SEPARATE_PROFILES' => '1']));
129129

130130
// collect metrics for startup, each benchmark run and shutdown
131131
$metricsArr = [];

‎benchmark/shared.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function __construct(
1313
) {}
1414
}
1515

16-
function runCommand(array $args, ?string $cwd = null): ProcessResult {
16+
function runCommand(array $args, ?string $cwd = null, ?array$envVars = null): ProcessResult {
1717
$cmd = implode('', array_map(function (string|UnescapedArg $v): string {
1818
return $v instanceof UnescapedArg
1919
? $v->arg
@@ -22,7 +22,7 @@ function runCommand(array $args, ?string $cwd = null): ProcessResult {
2222
$pipes = null;
2323
$descriptorSpec = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
2424
fwrite(STDOUT, "> $cmd\n");
25-
$processHandle = proc_open($cmd, $descriptorSpec, $pipes, $cwd ?? getcwd(), null);
25+
$processHandle = proc_open($cmd, $descriptorSpec, $pipes, $cwd ?? getcwd(), $envVars);
2626

2727
$stdin = $pipes[0];
2828
$stdout = $pipes[1];
@@ -60,7 +60,7 @@ function runCommand(array $args, ?string $cwd = null): ProcessResult {
6060

6161
fclose($stdout);
6262
fclose($stderr);
63-
63+
6464
$result = new ProcessResult($stdoutStr, $stderrStr);
6565

6666
$statusCode = proc_close($processHandle);

‎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)

AltStyle によって変換されたページ (->オリジナル) /