Skip to content

Commit a933bf0

Browse files
authored
adjust performance test
- fix svelte file path - slight test adjustment
1 parent fe74fc9 commit a933bf0

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

packages/language-server/test/plugins/typescript/typescript-performance.test.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,36 @@ describe('TypeScript Plugin Performance Tests', () => {
1717
const pluginManager = new LSConfigManager();
1818
const plugin = new TypeScriptPlugin(docManager, pluginManager, [pathToUrl(testDir)]);
1919
docManager.openDocument({ uri, text: document.getText() });
20-
const updateDocument = (newText: string) =>
20+
const append = (newText: string) =>
2121
docManager.updateDocument({ uri, version: 1 }, [
2222
{ range: Range.create(Position.create(9, 0), Position.create(9, 0)), text: newText }
2323
]);
24-
return { plugin, document, updateDocument };
24+
const prepend = (newText: string) =>
25+
docManager.updateDocument({ uri, version: 1 }, [
26+
{ range: Range.create(Position.create(1, 0), Position.create(1, 0)), text: newText }
27+
]);
28+
return { plugin, document, append, prepend };
2529
}
2630

2731
it('should be fast enough', async () => {
28-
const { document, plugin, updateDocument } = setup('performance');
32+
const { document, plugin, append, prepend } = setup('performance.svelte');
2933

3034
const start = performance.now();
31-
for (let i = 0; i < 1000; i++) {
32-
await plugin.doHover(document, Position.create(1, 15));
35+
for (let i = 0; i < 100; i++) {
36+
const position = Position.create(Math.floor(i / 2) + 1, 15);
37+
await plugin.doHover(document, position);
3338
await plugin.getDiagnostics(document);
34-
await plugin.findReferences(document, Position.create(1, 15), {
39+
await plugin.findReferences(document, position, {
3540
includeDeclaration: true
3641
});
3742
await plugin.getDocumentSymbols(document);
3843
await plugin.getSemanticTokens(document);
39-
await plugin.prepareRename(document, Position.create(1, 15));
40-
updateDocument('function asd() {}\n');
44+
await plugin.prepareRename(document, position);
45+
if (i % 2) {
46+
prepend('function asd() {}\n');
47+
} else {
48+
append('function asd() {}\n');
49+
}
4150
}
4251
const end = performance.now();
4352

0 commit comments

Comments
 (0)