2018-10-26 06:59:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
ini_set('display_startup_errors', '1');
|
|
|
|
ini_set('html_errors', '1');
|
2019-01-02 17:18:22 +01:00
|
|
|
ini_set('memory_limit', '4G');
|
2018-10-26 06:59:14 +02:00
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
2018-12-01 21:29:14 +01:00
|
|
|
gc_disable();
|
|
|
|
|
2018-10-26 06:59:14 +02:00
|
|
|
require __DIR__ . '../../../vendor/autoload.php';
|
|
|
|
|
|
|
|
$a = file_get_contents(__DIR__ . '/a.test');
|
|
|
|
$b = file_get_contents(__DIR__ . '/b.test');
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$a_stmts = Psalm\Internal\Provider\StatementsProvider::parseStatements($a);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$time = microtime(true);
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$file_changes = Psalm\Internal\Diff\FileDiffer::getDiff($a, $b);
|
2018-10-26 06:59:14 +02:00
|
|
|
$dlt = microtime(true);
|
|
|
|
$line_diff_time = $dlt - $time;
|
|
|
|
|
|
|
|
echo 'Partial parsing: diffing lines: ' . number_format($line_diff_time, 4) . "\n";
|
|
|
|
|
|
|
|
$traverser = new PhpParser\NodeTraverser;
|
2018-11-06 03:57:36 +01:00
|
|
|
$traverser->addVisitor(new Psalm\Internal\Visitor\CloningVisitor);
|
2018-10-26 06:59:14 +02:00
|
|
|
// performs a deep clone
|
|
|
|
/** @var array<int, PhpParser\Node\Stmt> */
|
|
|
|
$a_stmts_copy = $traverser->traverse($a_stmts);
|
|
|
|
$dlt2 = microtime(true);
|
|
|
|
|
|
|
|
echo 'Partial parsing: cloning: ' . number_format($dlt2 - $dlt, 4) . "\n";
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
Psalm\Internal\Provider\StatementsProvider::parseStatements($b, null, $a, $a_stmts_copy, $file_changes);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$diff_1 = microtime(true) - $time;
|
|
|
|
|
|
|
|
echo 'Partial parsing: ' . number_format($diff_1, 4) . "\n";
|
|
|
|
|
|
|
|
$time = microtime(true);
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
Psalm\Internal\Provider\StatementsProvider::parseStatements($b);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$diff_2 = microtime(true) - $time;
|
|
|
|
|
|
|
|
echo 'Full parsing: ' . number_format($diff_2, 4) . "\n";
|
2019-01-02 17:18:22 +01:00
|
|
|
|
|
|
|
echo strlen($a);
|
|
|
|
|
|
|
|
Psalm\Internal\Diff\FileDiffer::getDiff($a, '');
|