|
| 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