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 a978f8c

Browse files
committed
use Ir median as main metrics
1 parent 80ba146 commit a978f8c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

‎benchmark/benchmark.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,24 @@ function runValgrindPhpCgiCommand(
139139
// print all collected metrics
140140
print_r(array_map(fn ($metrics) => array_map(fn ($v) => number_format($v, 0, '.', '_'), $metrics), $metricsArr));
141141

142-
// find the fastest benchmark run
143-
$bestRunIndex = 0;
144-
foreach (range(0, $repeat - 1) as $k) {
145-
if ($metricsArr[$k]['Ir'] < $metricsArr[$bestRunIndex]['Ir']) {
146-
$bestRunIndex = $k;
147-
}
148-
}
149-
150-
// remove non-fastest profiles from artifacts
142+
// find median benchmark run
143+
$metricsForMedianArr = $metricsArr;
144+
unset($metricsForMedianArr['startup']);
145+
unset($metricsForMedianArr['shutdown']);
146+
uasort($metricsForMedianArr, fn ($a, $b) => $a['Ir'] <=> $b['Ir']);
147+
$medianRunIndex = array_keys($metricsForMedianArr)[max(0, floor((count($metricsForMedianArr) - 3 /* -1 for count to index, -1 for first slow run due compliation, -1 for second run which is a little slower too */) / 2.0))];
148+
149+
// remove non-median profiles from artifacts
151150
foreach (range(0, $repeat - 1) as $k) {
152151
$profileOutSpecific = $profileOut . '.' . $k;
153152

154-
if ($k !== $bestRunIndex) {
153+
if ($k !== $medianRunIndex) {
155154
unlink($profileOutSpecific);
156155
}
157156
}
158157

159158
// annotate profiles for artifacts
160-
foreach (['startup', $bestRunIndex, 'shutdown'] as $k) {
159+
foreach (['startup', $medianRunIndex, 'shutdown'] as $k) {
161160
$profileOutSpecific = $profileOut . '.' . $k;
162161

163162
runCommand([
@@ -171,7 +170,7 @@ function runValgrindPhpCgiCommand(
171170
]);
172171
}
173172

174-
return ['instructions' => $metricsArr[$bestRunIndex]['Ir']];
173+
return ['instructions' => $metricsArr[$medianRunIndex]['Ir']];
175174
}
176175

177176
/**

0 commit comments

Comments
(0)

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