From 864a7a862169ad59c46b3cb500eab112d7f1e4f0 Mon Sep 17 00:00:00 2001 From: Sara Itani Date: Mon, 10 Apr 2017 14:19:55 -0700 Subject: [PATCH] test multipe frameworks in perf test script --- Performance.php | 110 ++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/Performance.php b/Performance.php index 1416c95..7b8e6b3 100644 --- a/Performance.php +++ b/Performance.php @@ -18,65 +18,65 @@ use RecursiveIteratorIterator; use Sabre\Event\Loop; $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 (new RecursiveIteratorIterator($iterator) as $file) { - if (strpos((string)$file, ".php") !== false) { - $totalSize += $file->getSize(); - $testProviderArray[] = $file->getPathname(); - } -} +foreach($frameworks as $framework) { + $iterator = new RecursiveDirectoryIterator(__DIR__ . "/validation/frameworks/$framework"); + $testProviderArray = array(); -if (count($testProviderArray) === 0) { - throw new Exception("ERROR: Validation testsuite frameworks not found - run `git submodule update --init --recursive` to download."); -} - -$start = microtime(true); - -$documents = []; -foreach ($testProviderArray as $idx=>$testCaseFile) { - if ($idx > 100) { - break; - } - - echo "$idx=>$testCaseFile\n"; - - $fileContents = file_get_contents($testCaseFile); - - $docBlockFactory = DocBlockFactory::createInstance(); - $index = new Index; - - $parserKinds = [ParserKind::DIAGNOSTIC_PHP_PARSER, ParserKind::DIAGNOSTIC_TOLERANT_PHP_PARSER]; - - $maxRecursion = []; - foreach ($parserKinds as $kind) { - global $parserKind; - $parserKind = $kind; - - $definitionResolver = ParserResourceFactory::getDefinitionResolver($index); - $parser = ParserResourceFactory::getParser(); - - - try { - $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) { -// echo "AAAHH\n"; - continue; + foreach (new RecursiveIteratorIterator($iterator) as $file) { + if (strpos((string)$file, ".php") !== false) { + $totalSize += $file->getSize(); + $testProviderArray[] = $file->getPathname(); } } + + if (count($testProviderArray) === 0) { + 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); + + foreach ($testProviderArray as $idx => $testCaseFile) { + // if ($idx < 20) { + // continue; + // } + if (filesize($testCaseFile) > 10000) { + continue; + } + if ($idx % 1000 === 0) { + echo "$idx\n"; + } + +// echo "$idx=>$testCaseFile\n"; + + $fileContents = file_get_contents($testCaseFile); + + $docBlockFactory = DocBlockFactory::createInstance(); + $index = new Index; + $maxRecursion = []; + $definitions = []; + global $parserKind; + $parserKind = $kind; + + $definitionResolver = ParserResourceFactory::getDefinitionResolver($index); + $parser = ParserResourceFactory::getParser(); + + try { + $document = new PhpDocument($testCaseFile, $fileContents, $index, $parser, $docBlockFactory, $definitionResolver); + } catch (\Exception $e) { + continue; + } + } + + echo "------------------------------\n"; + + echo "Time [$framework, $kind]: " . (microtime(true) - $start) . PHP_EOL; + + } } -echo "------------------------------\n"; -var_dump($documents); - -echo "Time: " . (microtime(true) - $start) . PHP_EOL;