test multipe frameworks in perf test script
parent
3d5d46d4e7
commit
864a7a8621
|
@ -18,9 +18,12 @@ use RecursiveIteratorIterator;
|
||||||
use Sabre\Event\Loop;
|
use Sabre\Event\Loop;
|
||||||
|
|
||||||
$totalSize = 0;
|
$totalSize = 0;
|
||||||
$testProviderArray = array();
|
|
||||||
|
|
||||||
$iterator = new RecursiveDirectoryIterator(__DIR__ . "/validation/frameworks/WordPress");
|
$frameworks = ["drupal", "wordpress", "php-language-server", "tolerant-php-parser", "math-php", "symfony", "CodeIgniter", "cakephp"];
|
||||||
|
|
||||||
|
foreach($frameworks as $framework) {
|
||||||
|
$iterator = new RecursiveDirectoryIterator(__DIR__ . "/validation/frameworks/$framework");
|
||||||
|
$testProviderArray = array();
|
||||||
|
|
||||||
foreach (new RecursiveIteratorIterator($iterator) as $file) {
|
foreach (new RecursiveIteratorIterator($iterator) as $file) {
|
||||||
if (strpos((string)$file, ".php") !== false) {
|
if (strpos((string)$file, ".php") !== false) {
|
||||||
|
@ -33,50 +36,47 @@ if (count($testProviderArray) === 0) {
|
||||||
throw new Exception("ERROR: Validation testsuite frameworks not found - run `git submodule update --init --recursive` to download.");
|
throw new Exception("ERROR: Validation testsuite frameworks not found - run `git submodule update --init --recursive` to download.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$parserKinds = [ParserKind::PHP_PARSER, ParserKind::TOLERANT_PHP_PARSER];
|
||||||
|
foreach ($parserKinds as $kind) {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|
||||||
$documents = [];
|
|
||||||
foreach ($testProviderArray as $idx => $testCaseFile) {
|
foreach ($testProviderArray as $idx => $testCaseFile) {
|
||||||
if ($idx > 100) {
|
// if ($idx < 20) {
|
||||||
break;
|
// continue;
|
||||||
|
// }
|
||||||
|
if (filesize($testCaseFile) > 10000) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($idx % 1000 === 0) {
|
||||||
|
echo "$idx\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "$idx=>$testCaseFile\n";
|
// echo "$idx=>$testCaseFile\n";
|
||||||
|
|
||||||
$fileContents = file_get_contents($testCaseFile);
|
$fileContents = file_get_contents($testCaseFile);
|
||||||
|
|
||||||
$docBlockFactory = DocBlockFactory::createInstance();
|
$docBlockFactory = DocBlockFactory::createInstance();
|
||||||
$index = new Index;
|
$index = new Index;
|
||||||
|
|
||||||
$parserKinds = [ParserKind::DIAGNOSTIC_PHP_PARSER, ParserKind::DIAGNOSTIC_TOLERANT_PHP_PARSER];
|
|
||||||
|
|
||||||
$maxRecursion = [];
|
$maxRecursion = [];
|
||||||
foreach ($parserKinds as $kind) {
|
$definitions = [];
|
||||||
global $parserKind;
|
global $parserKind;
|
||||||
$parserKind = $kind;
|
$parserKind = $kind;
|
||||||
|
|
||||||
$definitionResolver = ParserResourceFactory::getDefinitionResolver($index);
|
$definitionResolver = ParserResourceFactory::getDefinitionResolver($index);
|
||||||
$parser = ParserResourceFactory::getParser();
|
$parser = ParserResourceFactory::getParser();
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$document = new PhpDocument($testCaseFile, $fileContents, $index, $parser, $docBlockFactory, $definitionResolver);
|
$document = new PhpDocument($testCaseFile, $fileContents, $index, $parser, $docBlockFactory, $definitionResolver);
|
||||||
if ($document->getStmts() === null) {
|
|
||||||
echo "AHHHHHHHHHH\n";
|
|
||||||
}
|
|
||||||
if (isset($maxRecursion[$testCaseFile]) && $maxRecursion[$testCaseFile] !== ($max = $definitionResolver::$maxRecursion)) {
|
|
||||||
$documents[] = "$testCaseFile\n => OLD: $maxRecursion[$testCaseFile], NEW: $max";
|
|
||||||
}
|
|
||||||
$maxRecursion[$testCaseFile] = $definitionResolver::$maxRecursion;
|
|
||||||
// $definitionResolver->printLogs();
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// echo "AAAHH\n";
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
echo "------------------------------\n";
|
echo "------------------------------\n";
|
||||||
var_dump($documents);
|
|
||||||
|
|
||||||
echo "Time: " . (microtime(true) - $start) . PHP_EOL;
|
echo "Time [$framework, $kind]: " . (microtime(true) - $start) . PHP_EOL;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue