Skip to content

Commit cefd428

Browse files
Update
1 parent e642d0d commit cefd428

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

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

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,47 @@ const obj = Object.fromEntries(
2222
const content = JSON.stringify(obj, null, 2);
2323
const numLines = content.split("\n").length;
2424

25+
const textBasedThreshold = 50;
26+
const parseTreeThreshold = 300;
27+
const surroundingPairThreshold = 20000;
28+
2529
suite(`Performance: ${numLines} lines JSON`, async function () {
2630
endToEndTestSetup(this);
2731

32+
let previousTitle = "";
33+
2834
this.beforeEach(function () {
29-
// console.log("before");
30-
// console.log(a.name);
31-
console.log(this.test?.title);
32-
console.log(this.test?.id);
35+
const title = this.currentTest!.title;
36+
if (title !== previousTitle) {
37+
console.debug(` * ${title}`);
38+
previousTitle = title;
39+
}
3340
});
3441

35-
this.afterAll(() => {
36-
console.log("Done!");
37-
});
42+
test(
43+
"Remove token",
44+
asyncSafety(() => removeToken(textBasedThreshold)),
45+
);
3846

3947
const scopeTypeTypes: Partial<Record<SimpleScopeTypeType, number>> = {
40-
character: 100,
41-
word: 100,
42-
token: 100,
43-
identifier: 100,
44-
line: 100,
45-
sentence: 100,
46-
paragraph: 100,
47-
// boundedParagraph: 100,
48-
document: 100,
49-
nonWhitespaceSequence: 100,
50-
// boundedNonWhitespaceSequence: 300,
51-
// string: 100,
52-
map: 100,
53-
// collectionKey: 300,
54-
// value: 15000,
48+
// Text based
49+
character: textBasedThreshold,
50+
word: textBasedThreshold,
51+
token: textBasedThreshold,
52+
identifier: textBasedThreshold,
53+
line: textBasedThreshold,
54+
sentence: textBasedThreshold,
55+
paragraph: textBasedThreshold,
56+
document: textBasedThreshold,
57+
nonWhitespaceSequence: textBasedThreshold,
58+
// Parse tree based
59+
string: parseTreeThreshold,
60+
map: parseTreeThreshold,
61+
collectionKey: parseTreeThreshold,
62+
value: parseTreeThreshold,
63+
// Utilizes surrounding pair
64+
boundedParagraph: surroundingPairThreshold,
65+
boundedNonWhitespaceSequence: surroundingPairThreshold,
5566
};
5667

5768
for (const [scopeTypeType, threshold] of Object.entries(scopeTypeTypes)) {
@@ -66,21 +77,19 @@ suite(`Performance: ${numLines} lines JSON`, async function () {
6677
);
6778
}
6879

69-
// test(
70-
// "Select any surrounding pair",
71-
// asyncSafety(() =>
72-
// selectScopeType({ type: "surroundingPair", delimiter: "any" }, 300),
73-
// ),
74-
// );
75-
7680
test(
77-
"Remove token",
78-
asyncSafety(() => removeToken()),
81+
"Select any surrounding pair",
82+
asyncSafety(() =>
83+
selectScopeType(
84+
{ type: "surroundingPair", delimiter: "any" },
85+
surroundingPairThreshold,
86+
),
87+
),
7988
);
8089
});
8190

82-
async function removeToken() {
83-
await testPerformance(100, {
91+
async function removeToken(threshold: number) {
92+
await testPerformance(threshold, {
8493
name: "remove",
8594
target: {
8695
type: "primitive",
@@ -116,7 +125,7 @@ async function testPerformance(threshold: number, action: ActionDescriptor) {
116125

117126
const duration = Math.round(performance.now() - start);
118127

119-
console.debug(`\t${duration} ms`);
128+
console.debug(` ${duration} ms`);
120129

121130
assert.ok(
122131
duration < threshold,

0 commit comments

Comments
 (0)