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 76b989c

Browse files
committed
allow to parse more than one/Ir callgrind metric
1 parent 414ff23 commit 76b989c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎benchmark/benchmark.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,23 @@ function runValgrindPhpCgiCommand(
123123
'-d opcache.validate_timestamps=0',
124124
...$args,
125125
]);
126-
$instructions = extractInstructionsFromValgrindOutput($process->stderr);
126+
$valgrindMetrics = extractMetricsFromValgrindOutput($process->stderr);
127+
$instructions = $valgrindMetrics['Ir'];
127128
if ($repeat > 1) {
128129
$instructions = gmp_strval(gmp_div_q($instructions, $repeat));
129130
}
130131
return ['instructions' => $instructions];
131132
}
132133

133-
function extractInstructionsFromValgrindOutput(string $output): string {
134-
preg_match("(==[0-9]+== Events : Ir\n==[0-9]+== Collected : (?<instructions>[0-9]+))", $output, $matches);
135-
return $matches['instructions'] ?? throw new \Exception('Unexpected valgrind output');
134+
/**
135+
* @return array<non-empty-string, numeric-string>
136+
*/
137+
function extractMetricsFromValgrindOutput(string $output): array {
138+
if (!preg_match('/==\d+== Events *:((?: +\w+)+)\n==\d+== Collected :((?: +\d+)+)\n/', $output, $matches)) {
139+
throw new \Exception('Unexpected valgrind output: ' . $output);
140+
}
141+
142+
return array_combine(explode('', ltrim($matches[1], '')), explode('', ltrim($matches[2], '')));
136143
}
137144

138145
main();

0 commit comments

Comments
(0)

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