The following files were used for tested, each wrapped in if (false) {}
to avoid class redefinition errors.
Last active
October 28, 2021 07:57
-
-
Save nikic/289b0c7538b46c2220bc to your computer and use it in GitHub Desktop.
Scripts for measuring compile time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php ini_set('memory_limit', -1); | |
if ($argc != 3) die("error\n"); | |
$file = $argv[1]; | |
$num = $argv[2]; | |
$startTime = microtime(true); | |
for ($i = 0; $i < $num; ++$i) { | |
require $file; | |
} | |
echo "Compile time: ", microtime(true) - $startTime, " seconds\n"; | |
echo "Peak memory usage: ", memory_get_peak_usage(), " bytes\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php error_reporting(E_ALL); | |
$dir = __DIR__ . '/../PHP-Parser/lib'; | |
spl_autoload_register(function($class) use($dir) { | |
if (strpos($class, 'PhpParser') === 0) { | |
require $dir . '/' . strtr($class, '\\', '/') . '.php'; | |
} | |
}); | |
$it = new RecursiveIteratorIterator( | |
new RecursiveDirectoryIterator($dir . '/PhpParser'), RecursiveIteratorIterator::LEAVES_ONLY); | |
$startTime = microtime(true); | |
foreach ($it as $file) { | |
if (!$file->isFile()) continue; | |
require_once $file; | |
} | |
echo "Compile time: ", microtime(true) - $startTime, " seconds\n"; | |
echo "Peak memory usage: ", memory_get_peak_usage(), " bytes\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment