diff --git a/test/testAgainstDirectory.php b/test/testAgainstDirectory.php index e660cff..63aecb1 100644 --- a/test/testAgainstDirectory.php +++ b/test/testAgainstDirectory.php @@ -16,14 +16,15 @@ echo ' - '; -$totalStartTime = microtime(true); $parseFail = $parseCount = $ppFail = $ppCount = $compareFail = $compareCount = 0; +$totalStartTime = microtime(true); +$parseTime = $ppTime = $compareTime = 0; + foreach (new RecursiveIteratorIterator( new RecursiveDirectoryIterator($DIR), RecursiveIteratorIterator::LEAVES_ONLY) @@ -39,41 +40,44 @@ foreach (new RecursiveIteratorIterator( set_time_limit(10); $errMsg = ''; - $startTime = microtime(true); + ++$parseCount; + $parseTime -= microtime(true); $stmts = $parser->parse( new Lexer(file_get_contents($file)), - function($msg) use (&$errMsg) { + function ($msg) use (&$errMsg) { $errMsg = $msg; } ); + $parseTime += microtime(true); - $time = microtime(true) - $startTime; - - ++$parseCount; if (false !== $stmts) { + ++$ppCount; + $ppTime -= microtime(true); $code = 'pStmts($stmts); + $ppTime += microtime(true); $ppStmts = $parser->parse( new Lexer($code), - function($msg) use (&$errMsg) { + function ($msg) use (&$errMsg) { $errMsg = $msg; } ); - ++$ppCount; if (false !== $ppStmts) { ++$compareCount; - if ($nodeDumper->dump($stmts) == $nodeDumper->dump($ppStmts)) { + $compareTime -= microtime(true); + $same = $nodeDumper->dump($stmts) == $nodeDumper->dump($ppStmts); + $compareTime += microtime(true); + + if ($same) { echo ' - '; } else { echo ' - '; @@ -83,7 +87,6 @@ foreach (new RecursiveIteratorIterator( } else { echo ' - '; @@ -93,7 +96,6 @@ foreach (new RecursiveIteratorIterator( } else { echo ' - @@ -109,10 +111,16 @@ echo ' - + + + + + +
File ParseTime PrettyPrint Compare
PASS' . $time . 's PASS PASS
PASS' . $time . 's PASS FAIL
PASS' . $time . 's FAIL
FAIL' . $time . 's
Fail / Total: ' . $parseFail . ' / ' . $parseCount . ' ' . $ppFail . ' / ' . $ppCount . ' ' . $compareFail . ' / ' . $compareCount . '
Time:' . $parseTime . '' . $ppTime . '' . $compareTime . '
'; -echo 'Total time: ', microtime(true) - $totalStartTime; \ No newline at end of file +echo 'Total time: ', microtime(true) - $totalStartTime, '
', + 'Maximum memory usage: ', memory_get_peak_usage(true); \ No newline at end of file