Skip to content

Commit c274f4e

Browse files
Use full test for surrounding pairs
1 parent d7a82a1 commit c274f4e

File tree

1 file changed

+30
-38
lines changed

1 file changed

+30
-38
lines changed

packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@ import * as vscode from "vscode";
1010
import { endToEndTestSetup } from "../endToEndTestSetup";
1111

1212
const testData = generateTestData(100);
13-
const shortTestData = generateTestData(30);
1413

15-
const textBasedConfig: TestConfig = { thresholdMs: 100, testData };
16-
const parseTreeConfig: TestConfig = { thresholdMs: 500, testData };
17-
const surroundingPairConfig: TestConfig = {
18-
thresholdMs: 500,
19-
testData: shortTestData,
20-
};
14+
const textBasedThresholdMs = 100;
15+
const parseTreeThresholdMs = 500;
16+
const surroundingPairThresholdMs = 500;
2117

2218
suite("Performance", async function () {
2319
endToEndTestSetup(this);
2420

2521
let previousTitle = "";
2622

23+
// Before each test, print the test title. This is done we have the test
24+
// title before the test run time / duration.
2725
this.beforeEach(function () {
2826
const title = this.currentTest!.title;
2927
if (title !== previousTitle) {
@@ -34,34 +32,34 @@ suite("Performance", async function () {
3432

3533
test(
3634
"Remove token",
37-
asyncSafety(() => removeToken(textBasedConfig)),
35+
asyncSafety(() => removeToken(textBasedThresholdMs)),
3836
);
3937

40-
const fixtures: [SimpleScopeTypeType | ScopeType, TestConfig][] = [
38+
const fixtures: [SimpleScopeTypeType | ScopeType, number][] = [
4139
// Text based
42-
["character", textBasedConfig],
43-
["word", textBasedConfig],
44-
["token", textBasedConfig],
45-
["identifier", textBasedConfig],
46-
["line", textBasedConfig],
47-
["sentence", textBasedConfig],
48-
["paragraph", textBasedConfig],
49-
["document", textBasedConfig],
50-
["nonWhitespaceSequence", textBasedConfig],
40+
["character", textBasedThresholdMs],
41+
["word", textBasedThresholdMs],
42+
["token", textBasedThresholdMs],
43+
["identifier", textBasedThresholdMs],
44+
["line", textBasedThresholdMs],
45+
["sentence", textBasedThresholdMs],
46+
["paragraph", textBasedThresholdMs],
47+
["document", textBasedThresholdMs],
48+
["nonWhitespaceSequence", textBasedThresholdMs],
5149
// Parse tree based
52-
["string", parseTreeConfig],
53-
["map", parseTreeConfig],
54-
["collectionKey", parseTreeConfig],
55-
["value", parseTreeConfig],
50+
["string", parseTreeThresholdMs],
51+
["map", parseTreeThresholdMs],
52+
["collectionKey", parseTreeThresholdMs],
53+
["value", parseTreeThresholdMs],
5654
// Text based, but utilizes surrounding pair
57-
["boundedParagraph", surroundingPairConfig],
58-
["boundedNonWhitespaceSequence", surroundingPairConfig],
59-
["collectionItem", surroundingPairConfig],
55+
["boundedParagraph", surroundingPairThresholdMs],
56+
["boundedNonWhitespaceSequence", surroundingPairThresholdMs],
57+
["collectionItem", surroundingPairThresholdMs],
6058
// Surrounding pair
61-
[{ type: "surroundingPair", delimiter: "any" }, surroundingPairConfig],
59+
[{ type: "surroundingPair", delimiter: "any" }, surroundingPairThresholdMs],
6260
[
6361
{ type: "surroundingPair", delimiter: "curlyBrackets" },
64-
surroundingPairConfig,
62+
surroundingPairThresholdMs,
6563
],
6664
];
6765

@@ -74,8 +72,8 @@ suite("Performance", async function () {
7472
}
7573
});
7674

77-
async function removeToken(config: TestConfig) {
78-
await testPerformance(config, {
75+
async function removeToken(thresholdMs: number) {
76+
await testPerformance(thresholdMs, {
7977
name: "remove",
8078
target: {
8179
type: "primitive",
@@ -84,8 +82,8 @@ async function removeToken(config: TestConfig) {
8482
});
8583
}
8684

87-
async function selectScopeType(scopeType: ScopeType, config: TestConfig) {
88-
await testPerformance(config, {
85+
async function selectScopeType(scopeType: ScopeType, thresholdMs: number) {
86+
await testPerformance(thresholdMs, {
8987
name: "setSelection",
9088
target: {
9189
type: "primitive",
@@ -94,8 +92,7 @@ async function selectScopeType(scopeType: ScopeType, config: TestConfig) {
9492
});
9593
}
9694

97-
async function testPerformance(config: TestConfig, action: ActionDescriptor) {
98-
const { testData, thresholdMs } = config;
95+
async function testPerformance(thresholdMs: number, action: ActionDescriptor) {
9996
const editor = await openNewEditor(testData, { languageId: "json" });
10097
const position = new vscode.Position(editor.document.lineCount - 3, 5);
10198
const selection = new vscode.Selection(position, position);
@@ -150,8 +147,3 @@ function generateTestData(n: number): string {
150147
);
151148
return JSON.stringify(obj, null, 2);
152149
}
153-
154-
interface TestConfig {
155-
thresholdMs: number;
156-
testData: string;
157-
}

0 commit comments

Comments
 (0)