Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions benchmark/benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

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.");
}
}
checkExtensions(['gmp']);

$storeResult = ($argv[1] ?? 'false') === 'true';
$phpCgi = $argv[2] ?? dirname(PHP_BINARY) . '/php-cgi';
Expand All @@ -27,12 +23,18 @@ function main() {
if (false !== $branch = getenv('GITHUB_REF_NAME')) {
$data['branch'] = $branch;
}

$data['Zend/bench.php'] = runBench(false);
$data['Zend/bench.php JIT'] = runBench(true);

checkExtensions(['mbstring']);
$data['Symfony Demo 2.2.3'] = runSymfonyDemo(false);
$data['Symfony Demo 2.2.3 JIT'] = runSymfonyDemo(true);

checkExtensions(['mbstring', 'sockets', 'mysqli', 'openssl']);
$data['Wordpress 6.2'] = runWordpress(false);
$data['Wordpress 6.2 JIT'] = runWordpress(true);

$result = json_encode($data, JSON_PRETTY_PRINT) . "\n";

fwrite(STDOUT, $result);
Expand All @@ -42,6 +44,14 @@ function main() {
}
}

function checkExtensions(array $extensions): void {
foreach ($extensions as $ext) {
if (!extension_loaded($ext)) {
throw new LogicException("Extension $ext is required.");
}
}
}

function storeResult(string $result) {
$repo = __DIR__ . '/repos/data';
cloneRepo($repo, 'git@github.com:php/benchmarking-data.git');
Expand Down Expand Up @@ -136,9 +146,15 @@ function runValgrindPhpCgiCommand(
return ['instructions' => $instructions];
}

/**
* @return decimal-int-string
*/
function extractInstructionsFromValgrindOutput(string $output): string {
preg_match("(==[0-9]+== Events : Ir\n==[0-9]+== Collected : (?<instructions>[0-9]+))", $output, $matches);
return $matches['instructions'] ?? throw new \Exception('Unexpected valgrind output');
if (!preg_match("(==[0-9]+== Events : Ir\n==[0-9]+== Collected : (?<instructions>[0-9]+))", $output, $matches)) {
throw new \Exception('Unexpected valgrind output');
}

return $matches['instructions'];
Comment thread
mvorisek marked this conversation as resolved.
Outdated
}

main();
Loading