parse(new PHPParser_Lexer($code)); $parseTime += microtime(true) - $startTime; $startTime = microtime(true); $code = 'prettyPrint($stmts); $ppTime += microtime(true) - $startTime; try { $ppStmts = $parser->parse(new PHPParser_Lexer($code)); $startTime = microtime(true); $same = $nodeDumper->dump($stmts) == $nodeDumper->dump($ppStmts); $compareTime += microtime(true) - $startTime; if (!$same) { echo $file, ":\n Result of initial parse and parse after pretty print differ\n"; ++$compareFail; } } catch (PHPParser_Error $e) { echo $file, ":\n Parse of pretty print failed with message: {$e->getMessage()}\n"; ++$ppFail; } } catch (PHPParser_Error $e) { echo $file, ":\n Parse failed with message: {$e->getMessage()}\n"; ++$parseFail; } } if (0 === $parseFail && 0 === $ppFail && 0 === $compareFail) { echo 'All tests passed.', "\n"; } else { echo "\n", '==========', "\n\n", 'There were: ', "\n"; if (0 !== $parseFail) { echo ' ', $parseFail, ' parse failures.', "\n"; } if (0 !== $ppFail) { echo ' ', $ppFail, ' pretty print failures.', "\n"; } if (0 !== $compareFail) { echo ' ', $compareFail, ' compare failures.', "\n"; } } echo "\n", 'Tested files: ', $count, "\n", "\n", 'Parsing took: ', $parseTime, "\n", 'Pretty printing took: ', $ppTime, "\n", 'Comparing took: ', $compareTime, "\n", "\n", 'Total time: ', microtime(true) - $totalStartTime, "\n", 'Maximum memory usage: ', memory_get_peak_usage(true), "\n";