Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Scripts for measuring compile time
<?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";
<?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