-
Notifications
You must be signed in to change notification settings - Fork 187
Adopt Microsoft/tolerant-php-parser #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 144 commits
13241a7
027801e
df315df
591ecbd
b1eb435
e7b04f7
2280e78
722898f
15eed55
cdf8fc3
d3f2beb
c18bec0
1316761
d21e7e7
4653f10
1ff1b38
d02253c
afca7ea
e45648d
167b6ac
4324530
0824e6d
81ba7df
6e7f77b
7b633f5
cd4c6d6
c84b91d
946b5b1
4ac56d8
a69c93b
42dc2c9
105f9bf
a5fec94
d62bdea
7d68e3a
fa52aef
651e6be
21cee77
b02c164
3d5d46d
864a7a8
5996544
5bd827f
219c018
e6ba591
981b74a
57ebd58
39fe9dc
0b0cad2
35ce3af
d6d9712
ed2a591
8d11ec7
05bccec
26152b1
52d70a2
596d7f0
2ab7fc0
6d39d87
4382821
54f385f
65686c6
f5a93a2
bfbad09
347a5a1
223a2ea
ed64692
76c8536
3e22956
7940ea4
8af671e
f201ecd
4d47671
587822b
ede5edc
ce548de
dc67337
bb94aea
30da705
31441f4
57f9e1f
de08134
addc862
1bb710f
22ddb81
403e0c5
e46d0de
90b40ef
253f9b5
91f1379
1fa29cc
67081c4
b541262
f2e6e3a
fc3e8ef
a9be548
552d99e
5e9dfa1
cf9590b
71d71a8
442fc7e
b4e77f2
6e1f638
d7a4034
97937ea
f51af8b
836cdb7
3dfe505
9c35aa6
2248148
05aa935
2568a42
de44ce5
077f0be
260969b
f144ca7
d56d1b7
e0a7b21
65363b7
f16866a
f1c0cc5
3cb0c03
01e7243
825c671
eef8244
aba798a
d4cabc6
70cf60e
829d307
af5a5fe
b2a849d
586b0d6
fc7d7f4
344a2ce
0a15afc
cfc8cc7
ae37940
eda52a8
1d314de
68656d9
4ade5fd
3131a9c
54073c5
adf65e5
a1ae0f6
bc5717a
d3d7f7d
9ad3c5a
4b573ac
4486ea0
349d3cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ vendor/ | |
| .phpls/ | ||
| composer.lock | ||
| stubs | ||
| *.ast | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [submodule "validation/frameworks/php-language-server"] | ||
| path = validation/frameworks/php-language-server | ||
| url = https://github.com/felixfbecker/php-language-server | ||
| [submodule "validation/frameworks/wordpress"] | ||
| path = validation/frameworks/wordpress | ||
| url = https://github.com/wordpress/wordpress | ||
| [submodule "validation/frameworks/drupal"] | ||
| path = validation/frameworks/drupal | ||
| url = https://github.com/drupal/drupal | ||
| [submodule "validation/frameworks/tolerant-php-parser"] | ||
| path = validation/frameworks/tolerant-php-parser | ||
| url = https://github.com/microsoft/tolerant-php-parser | ||
| [submodule "validation/frameworks/symfony"] | ||
| path = validation/frameworks/symfony | ||
| url = https://github.com/symfony/symfony | ||
| [submodule "validation/frameworks/math-php"] | ||
| path = validation/frameworks/math-php | ||
| url = https://github.com/markrogoyski/math-php | ||
| [submodule "validation/frameworks/codeigniter"] | ||
| path = validation/frameworks/codeigniter | ||
| url = https://github.com/bcit-ci/codeigniter | ||
| [submodule "validation/frameworks/cakephp"] | ||
| path = validation/frameworks/cakephp | ||
| url = https://github.com/cakephp/cakephp | ||
| [submodule "validation/frameworks/phpunit"] | ||
| path = validation/frameworks/phpunit | ||
| url = https://github.com/sebastianbergmann/phpunit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <?php | ||
|
|
||
| namespace LanguageServer\Tests; | ||
| require __DIR__ . '/vendor/autoload.php'; | ||
|
|
||
| use Exception; | ||
| use LanguageServer\Index\Index; | ||
| use LanguageServer\ParserKind; | ||
| use LanguageServer\PhpDocument; | ||
| use LanguageServer\DefinitionResolver; | ||
| use Microsoft\PhpParser; | ||
| use phpDocumentor\Reflection\DocBlockFactory; | ||
| use RecursiveDirectoryIterator; | ||
| use RecursiveIteratorIterator; | ||
|
|
||
| $totalSize = 0; | ||
|
|
||
| $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) { | ||
| 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 (filesize($testCaseFile) > 10000) { | ||
| continue; | ||
| } | ||
| if ($idx % 1000 === 0) { | ||
| echo "$idx\n"; | ||
| } | ||
|
|
||
| $fileContents = file_get_contents($testCaseFile); | ||
|
|
||
| $docBlockFactory = DocBlockFactory::createInstance(); | ||
| $index = new Index; | ||
| $maxRecursion = []; | ||
| $definitions = []; | ||
|
|
||
| $definitionResolver = new DefinitionResolver($index); | ||
| $parser = new PhpParser\Parser(); | ||
|
|
||
| try { | ||
| $document = new PhpDocument($testCaseFile, $fileContents, $index, $parser, $docBlockFactory, $definitionResolver); | ||
| } catch (\Throwable $e) { | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| echo "------------------------------\n"; | ||
|
|
||
| echo "Time [$framework, $kind]: " . (microtime(true) - $start) . PHP_EOL; | ||
|
|
||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ | |
| }, | ||
| "require": { | ||
| "php": ">=7.0", | ||
| "nikic/php-parser": "^3.0.5", | ||
| "phpdocumentor/reflection-docblock": "^3.0", | ||
| "sabre/event": "^5.0", | ||
| "felixfbecker/advanced-json-rpc": "^2.0", | ||
|
|
@@ -38,16 +37,25 @@ | |
| "webmozart/glob": "^4.1", | ||
| "sabre/uri": "^2.0", | ||
| "jetbrains/phpstorm-stubs": "dev-master", | ||
| "composer/composer": "^1.3" | ||
| "composer/composer": "^1.3", | ||
| "Microsoft/tolerant-php-parser": "dev-master" | ||
| }, | ||
| "minimum-stability": "dev", | ||
| "repositories": [ | ||
| { | ||
| "type": "git", | ||
| "url": "https://github.com/Microsoft/tolerant-php-parser.git" | ||
| } | ||
| ], | ||
|
||
| "prefer-stable": true, | ||
| "autoload": { | ||
| "psr-4": { | ||
| "LanguageServer\\": "src/" | ||
| }, | ||
| "files" : [ | ||
| "src/utils.php" | ||
| "src/utils.php", | ||
| "src/FqnUtilities.php", | ||
| "src/ParserHelpers.php" | ||
| ] | ||
| }, | ||
| "autoload-dev": { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, this is a benchmark that is run manually and depends on the git submodules, correct?
not blocking, but what do you think about moving this to a function that returns can be called in ComposerScripts.php and also in a PHPUnit test that asserts it stays below a threshold and catches performance regressions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to write an assert that a test runs in less than N seconds. You can really only compare performance between two runs on a given machine under controlled conditions.
If you want to do this in Travis or something (which would be awesome) maybe we could have it check out the previous version and run the test, then immediately check out the new version and run the test, and run several times and average the runs. But you still have to think about other things happening on the same machine, filesystem caching, other environmental things out of our control, so it might still end up flaky. I think doing this right is out of scope of this PR.