Skip to content

Commit 9e07c93

Browse files
committed
minimize code dupe, increase thresholds
1 parent 93602fc commit 9e07c93

File tree

1 file changed

+49
-95
lines changed

1 file changed

+49
-95
lines changed

packages/core/src/test/codewhisperer/zipcode.test.ts

Lines changed: 49 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -35,105 +35,59 @@ async function setup(numberOfFiles: number, fileSize: number): Promise<SetupResu
3535
return { tempDir, tempFileName, transformQManifest, writeSpy }
3636
}
3737

38+
function performanceTestWrapper(numberOfFiles: number, fileSize: number) {
39+
return performanceTest(
40+
{
41+
testRuns: 10,
42+
linux: {
43+
userCpuUsage: 120,
44+
systemCpuUsage: 50,
45+
heapTotal: 4,
46+
},
47+
darwin: {
48+
userCpuUsage: 120,
49+
systemCpuUsage: 50,
50+
heapTotal: 4,
51+
},
52+
win32: {
53+
userCpuUsage: 120,
54+
systemCpuUsage: 50,
55+
heapTotal: 4,
56+
},
57+
},
58+
'zipCode',
59+
function () {
60+
return {
61+
setup: async () => await setup(numberOfFiles, fileSize),
62+
execute: async ({ tempDir, tempFileName, transformQManifest, writeSpy }: SetupResult) => {
63+
await zipCode({
64+
dependenciesFolder: {
65+
path: tempDir,
66+
name: tempFileName,
67+
},
68+
humanInTheLoopFlag: false,
69+
modulePath: tempDir,
70+
zipManifest: transformQManifest,
71+
})
72+
},
73+
verify: async (setup: SetupResult) => {
74+
assert.ok(
75+
setup.writeSpy.args.find((arg) => {
76+
return arg[0].endsWith('.zip')
77+
})
78+
)
79+
},
80+
}
81+
}
82+
)
83+
}
84+
3885
describe('zipCode', function () {
3986
describe('performance tests', function () {
4087
afterEach(function () {
4188
sinon.restore()
4289
})
43-
/**
44-
* 250 small 10 byte files.
45-
*/
46-
performanceTest(
47-
{
48-
testRuns: 10,
49-
linux: {
50-
userCpuUsage: 100,
51-
systemCpuUsage: 50,
52-
heapTotal: 4,
53-
},
54-
darwin: {
55-
userCpuUsage: 100,
56-
systemCpuUsage: 50,
57-
heapTotal: 4,
58-
},
59-
win32: {
60-
userCpuUsage: 100,
61-
systemCpuUsage: 50,
62-
heapTotal: 4,
63-
},
64-
},
65-
'many small files in zip',
66-
function () {
67-
return {
68-
setup: async () => await setup(250, 10),
69-
execute: async ({ tempDir, tempFileName, transformQManifest, writeSpy }: SetupResult) => {
70-
await zipCode({
71-
dependenciesFolder: {
72-
path: tempDir,
73-
name: tempFileName,
74-
},
75-
humanInTheLoopFlag: false,
76-
modulePath: tempDir,
77-
zipManifest: transformQManifest,
78-
})
79-
},
80-
verify: async (setup: SetupResult) => {
81-
assert.ok(
82-
setup.writeSpy.args.find((arg) => {
83-
return arg[0].endsWith('.zip')
84-
})
85-
)
86-
},
87-
}
88-
}
89-
)
90-
/**
91-
* 10 large 1 MB files.
92-
*/
93-
94-
performanceTest(
95-
{
96-
testRuns: 10,
97-
linux: {
98-
userCpuUsage: 100,
99-
systemCpuUsage: 50,
100-
heapTotal: 4,
101-
},
102-
darwin: {
103-
userCpuUsage: 100,
104-
systemCpuUsage: 50,
105-
heapTotal: 4,
106-
},
107-
win32: {
108-
userCpuUsage: 100,
109-
systemCpuUsage: 50,
110-
heapTotal: 4,
111-
},
112-
},
113-
'few large files',
114-
function () {
115-
return {
116-
setup: async () => await setup(10, 1000),
117-
execute: async ({ tempDir, tempFileName, transformQManifest, writeSpy }: SetupResult) => {
118-
await zipCode({
119-
dependenciesFolder: {
120-
path: tempDir,
121-
name: tempFileName,
122-
},
123-
humanInTheLoopFlag: false,
124-
modulePath: tempDir,
125-
zipManifest: transformQManifest,
126-
})
127-
},
128-
verify: async (setup: SetupResult) => {
129-
assert.ok(
130-
setup.writeSpy.args.find((arg) => {
131-
return arg[0].endsWith('.zip')
132-
})
133-
)
134-
},
135-
}
136-
}
137-
)
90+
performanceTestWrapper(250, 10)
91+
performanceTestWrapper(10, 1000)
13892
})
13993
})

0 commit comments

Comments
 (0)