This repository has been archived by the owner on Mar 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added benchmark for workspace update * Add a minimum delay for workspace updates * Fix CS * Do not use custom script location
- Loading branch information
Showing
9 changed files
with
326 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/tests/*/Workspace | ||
/composer.lock | ||
/.php_cs.cache | ||
/.phpbench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"bootstrap": "vendor/autoload.php", | ||
"path": "tests/LanguageServerCodeTransform/Benchmark" | ||
"path": [ | ||
"tests/LanguageServerCodeTransform/Benchmark", | ||
"tests/LanguageServerWorseReflection/Benchmark" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/LanguageServerWorseReflection/Benchmark/WorkspaceIndexBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Phpactor\Extension\LanguageServerWorseReflection\Tests\Benchmark; | ||
|
||
use PhpBench\Benchmark\Metadata\Annotations\Executor; | ||
use PhpBench\Benchmark\Metadata\Annotations\OutputTimeUnit; | ||
use PhpBench\Benchmark\Metadata\Annotations\Revs; | ||
use Phpactor\Extension\LanguageServerCompletion\Tests\IntegrationTestCase; | ||
use Phpactor\LanguageServer\Test\LanguageServerTester; | ||
use PhpBench\Benchmark\Metadata\Annotations\ParamProviders; | ||
use Generator; | ||
|
||
/** | ||
* @BeforeMethods({"setUp"}) | ||
* @OutputTimeUnit("milliseconds") | ||
* @Executor("local") | ||
*/ | ||
class WorkspaceIndexBench extends IntegrationTestCase | ||
{ | ||
/** | ||
* @var LanguageServerTester | ||
*/ | ||
private $tester; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->tester = $this->createTester(); | ||
$this->tester->initialize(); | ||
$this->tester->textDocument()->open('file:///foobar', ''); | ||
} | ||
|
||
/** | ||
* @ParamProviders({"provideUpdate"}) | ||
* @Revs(10) | ||
* @Iterations(10) | ||
*/ | ||
public function benchUpdate(array $params): void | ||
{ | ||
$this->tester->textDocument()->update('file:///foobar', $params['text']); | ||
} | ||
|
||
public function provideUpdate(): Generator | ||
{ | ||
$source = mb_str_split((string)file_get_contents( | ||
__DIR__ . '/source/source.php.example' | ||
), 1); | ||
|
||
$buffer = ''; | ||
|
||
foreach ($source as $index => $char) { | ||
$buffer .= $char; | ||
if (0 === $index % 1000) { | ||
yield 'length: ' . strlen($buffer) => [ | ||
'text' => $buffer | ||
]; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.