From ae2abcf3e8ecbbd5aeb34b6d851ea3f7a92939ec Mon Sep 17 00:00:00 2001 From: Julien Voisin Date: Tue, 16 Jul 2024 17:37:20 +0000 Subject: [PATCH] Add a check for required extensions in benchmark.php (#14811) This should prevent people from being disappointed by an unexpected error message when running the benchmark, namely: ``` jvoisin@chernabog 21:54 (master) ~/dev/php-src php ./benchmark/benchmark.php false sapi/cgi/php-cgi > 'valgrind' '--tool=callgrind' '--dump-instr=yes' '--callgrind-out-file=/home/jvoisin/dev/php-src/benchmark/profiles/callgrind.out.bench' '--' 'sapi/cgi/php-cgi' '-T1' '-d max_execution_time=0' '-d opcache.enable=1' '-d opcache.jit=disable' '-d opcache.jit_buffer_size=128M' '-d opcache.validate_timestamps=0' '/home/jvoisin/dev/php-src/Zend/bench.php' > 'valgrind' '--tool=callgrind' '--dump-instr=yes' '--callgrind-out-file=/home/jvoisin/dev/php-src/benchmark/profiles/callgrind.out.bench.jit' '--' 'sapi/cgi/php-cgi' '-T1' '-d max_execution_time=0' '-d opcache.enable=1' '-d opcache.jit=tracing' '-d opcache.jit_buffer_size=128M' '-d opcache.validate_timestamps=0' '/home/jvoisin/dev/php-src/Zend/bench.php' > '/usr/bin/php' '/home/jvoisin/dev/php-src/benchmark/repos/symfony-demo-2.2.3/bin/console' 'cache:clear' > '/usr/bin/php' '/home/jvoisin/dev/php-src/benchmark/repos/symfony-demo-2.2.3/bin/console' 'cache:warmup' > 'valgrind' '--tool=callgrind' '--dump-instr=yes' '--callgrind-out-file=/home/jvoisin/dev/php-src/benchmark/profiles/callgrind.out.symfony-demo' '--' 'sapi/cgi/php-cgi' '-T50,50' '-d max_execution_time=0' '-d opcache.enable=1' '-d opcache.jit=disable' '-d opcache.jit_buffer_size=128M' '-d opcache.validate_timestamps=0' '/home/jvoisin/dev/php-src/benchmark/repos/symfony-demo-2.2.3/public/index.php' PHP Fatal error: Uncaught Error: Call to undefined function gmp_strval() in /home/jvoisin/dev/php-src/benchmark/benchmark.php:128 Stack trace: thrown in /home/jvoisin/dev/php-src/benchmark/benchmark.php on line 128 [255] jvoisin@chernabog 12:05 (master) ~/dev/php-src ``` --- benchmark/benchmark.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index ec39e9f3310..0c2ac4c6010 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -2,6 +2,12 @@ require_once __DIR__ . '/shared.php'; +foreach (array("mbstring", "sockets", "mysqli", "openssl", "gmp") as $ext) { + if (!extension_loaded($ext)) { + throw new LogicException("Extension $ext is required."); + } +} + $storeResult = ($argv[1] ?? 'false') === 'true'; $phpCgi = $argv[2] ?? dirname(PHP_BINARY) . '/php-cgi'; if (!file_exists($phpCgi)) {