Skip to content

Commit 285325c

Browse files
committed
check extensions for exact purpose
1 parent d09ba21 commit 285325c

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

benchmark/benchmark.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
require_once __DIR__ . '/shared.php';
44

5-
foreach (array("mbstring", "sockets", "mysqli", "openssl", "gmp") as $ext) {
6-
if (!extension_loaded($ext)) {
7-
throw new LogicException("Extension $ext is required.");
8-
}
9-
}
5+
checkExtensions(['gmp']);
106

117
$storeResult = ($argv[1] ?? 'false') === 'true';
128
$phpCgi = $argv[2] ?? dirname(PHP_BINARY) . '/php-cgi';
@@ -27,12 +23,18 @@ function main() {
2723
if (false !== $branch = getenv('GITHUB_REF_NAME')) {
2824
$data['branch'] = $branch;
2925
}
26+
3027
$data['Zend/bench.php'] = runBench(false);
3128
$data['Zend/bench.php JIT'] = runBench(true);
29+
30+
checkExtensions(['mbstring']);
3231
$data['Symfony Demo 2.2.3'] = runSymfonyDemo(false);
3332
$data['Symfony Demo 2.2.3 JIT'] = runSymfonyDemo(true);
33+
34+
checkExtensions(['mbstring', 'sockets', 'mysqli', 'openssl']);
3435
$data['Wordpress 6.2'] = runWordpress(false);
3536
$data['Wordpress 6.2 JIT'] = runWordpress(true);
37+
3638
$result = json_encode($data, JSON_PRETTY_PRINT) . "\n";
3739

3840
fwrite(STDOUT, $result);
@@ -42,6 +44,14 @@ function main() {
4244
}
4345
}
4446

47+
function checkExtensions(array $extensions): void {
48+
foreach ($extensions as $ext) {
49+
if (!extension_loaded($ext)) {
50+
throw new LogicException("Extension $ext is required.");
51+
}
52+
}
53+
}
54+
4555
function storeResult(string $result) {
4656
$repo = __DIR__ . '/repos/data';
4757
cloneRepo($repo, 'git@github.com:php/benchmarking-data.git');

0 commit comments

Comments
 (0)