Skip to content

Commit 53b3edc

Browse files
committed
implement p test
1 parent 25c28d0 commit 53b3edc

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

packages/core/src/amazonqFeatureDev/session/sessionState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class ConversationNotStartedState implements Omit<SessionState, 'uploadId
5252
}
5353
}
5454

55-
function registerNewFiles(
55+
export function registerNewFiles(
5656
fs: VirtualFileSystem,
5757
newFileContents: NewFileZipContents[],
5858
uploadId: string,
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import assert from 'assert'
6+
import * as vscode from 'vscode'
7+
import { NewFileInfo, NewFileZipContents, registerNewFiles } from '../../../amazonqFeatureDev'
8+
import { VirtualFileSystem } from '../../../shared'
9+
import { performanceTest } from '../../../shared/performance/performance'
10+
import { getTestWorkspaceFolder } from '../../../testInteg/integrationTestsUtilities'
11+
12+
interface SetupResult {
13+
workspace: vscode.WorkspaceFolder
14+
fileContents: NewFileZipContents[]
15+
}
16+
17+
function getFileContents(numFiles: number, fileSize: number): NewFileZipContents[] {
18+
return Array.from({ length: numFiles }, (_, i) => {
19+
return {
20+
zipFilePath: `test-path-${i}`,
21+
fileContent: 'x'.repeat(fileSize),
22+
}
23+
})
24+
}
25+
26+
function performanceTestWrapper(label: string, numFiles: number, fileSize: number) {
27+
return performanceTest(
28+
{
29+
testRuns: 10,
30+
linux: {
31+
userCpuUsage: 200,
32+
systemCpuUsage: 35,
33+
heapTotal: 8,
34+
},
35+
darwin: {
36+
userCpuUsage: 200,
37+
systemCpuUsage: 35,
38+
heapTotal: 8,
39+
},
40+
win32: {
41+
userCpuUsage: 200,
42+
systemCpuUsage: 35,
43+
heapTotal: 8,
44+
},
45+
},
46+
label,
47+
function () {
48+
return {
49+
setup: async () => {
50+
const testWorkspaceUri = vscode.Uri.file(getTestWorkspaceFolder())
51+
const fileContents = getFileContents(numFiles, fileSize)
52+
return {
53+
workspace: {
54+
uri: testWorkspaceUri,
55+
name: 'test-workspace',
56+
index: 0,
57+
},
58+
fileContents: fileContents,
59+
}
60+
},
61+
execute: async (setup: SetupResult) => {
62+
return registerNewFiles(new VirtualFileSystem(), setup.fileContents, 'test-upload-id', [
63+
setup.workspace,
64+
])
65+
},
66+
verify: async (_setup: SetupResult, result: NewFileInfo[]) => {
67+
assert.strictEqual(result.length, numFiles)
68+
},
69+
}
70+
}
71+
)
72+
}
73+
74+
describe('registerNewFiles', function () {
75+
describe('performance tests', function () {
76+
performanceTestWrapper('1x10MB', 1, 10000)
77+
performanceTestWrapper('10x1000B', 10, 1000)
78+
performanceTestWrapper('100x100B', 100, 100)
79+
performanceTestWrapper('1000x10B', 1000, 10)
80+
performanceTestWrapper('10000x1B', 10000, 1)
81+
})
82+
})

0 commit comments

Comments
 (0)