Skip to content

Commit e5b5545

Browse files
authored
test(amazonq): performance test for hashing file in LSP. (aws#5720)
## Problem continuation of performance test work: aws#5670 ## Solution same as previous. CPU threshold set very high because it spikes pretty wildly on this one. ![image](https://github.com/user-attachments/assets/cc8a6ce9-1be1-4504-b4de-cbafd1241016) --- <!--- REMINDER: Ensure that your PR meets the guidelines in CONTRIBUTING.md --> License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 4df3106 commit e5b5545

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 path from 'path'
7+
import { getTestWorkspaceFolder } from '../integrationTestsUtilities'
8+
import { fs, getRandomString } from '../../shared'
9+
import { LspController } from '../../amazonq'
10+
import { performanceTest } from '../../shared/performance/performance'
11+
12+
function performanceTestWrapper(label: string, fileSize: number) {
13+
return performanceTest(
14+
{
15+
testRuns: 1,
16+
linux: {
17+
userCpuUsage: 400,
18+
systemCpuUsage: 35,
19+
heapTotal: 4,
20+
},
21+
darwin: {
22+
userCpuUsage: 400,
23+
systemCpuUsage: 35,
24+
heapTotal: 4,
25+
},
26+
win32: {
27+
userCpuUsage: 400,
28+
systemCpuUsage: 35,
29+
heapTotal: 4,
30+
},
31+
},
32+
label,
33+
function () {
34+
return {
35+
setup: async () => {
36+
const workspace = getTestWorkspaceFolder()
37+
const fileContent = getRandomString(fileSize)
38+
const testFile = path.join(workspace, 'test-file')
39+
await fs.writeFile(testFile, fileContent)
40+
41+
return testFile
42+
},
43+
execute: async (testFile: string) => {
44+
return await LspController.instance.getFileSha384(testFile)
45+
},
46+
verify: async (_testFile: string, result: string) => {
47+
assert.strictEqual(result.length, 96)
48+
},
49+
}
50+
}
51+
)
52+
}
53+
54+
describe('getFileSha384', function () {
55+
describe('performance tests', function () {
56+
performanceTestWrapper('1MB', 1000)
57+
performanceTestWrapper('2MB', 2000)
58+
performanceTestWrapper('4MB', 4000)
59+
performanceTestWrapper('8MB', 8000)
60+
})
61+
})

0 commit comments

Comments
 (0)