MCPcopy
hub / github.com/jestjs/jest / main

Function main

packages/jest-worker/__benchmarks__/test.js:132–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130}
131
132async function main() {
133 if (!globalThis.gc) {
134 throw new Error('GC not present, start with node --expose-gc');
135 }
136
137 const wFResults = [];
138 const jWResults = [];
139
140 for (let i = 0; i < iterations; i++) {
141 console.log('-'.repeat(75));
142
143 profile('worker farm');
144 const wF = await testWorkerFarm();
145 profileEnd('worker farm');
146 await sleep(3000);
147 globalThis.gc?.();
148
149 profile('jest worker');
150 const jW = await testJestWorker();
151 profileEnd('jest worker');
152 await sleep(3000);
153 globalThis.gc?.();
154
155 wFResults.push(wF);
156 jWResults.push(jW);
157
158 console.log('jest-worker:', jW);
159 console.log('worker-farm:', wF);
160 }
161
162 let wFGT = 0;
163 let wFPT = 0;
164 let jWGT = 0;
165 let jWPT = 0;
166
167 for (let i = 0; i < iterations; i++) {
168 wFGT += wFResults[i].globalTime;
169 wFPT += wFResults[i].processingTime;
170
171 jWGT += jWResults[i].globalTime;
172 jWPT += jWResults[i].processingTime;
173 }
174
175 console.log('-'.repeat(75));
176 console.log('total worker-farm:', {wFGT, wFPT});
177 console.log('total jest-worker:', {jWGT, jWPT});
178
179 console.log('-'.repeat(75));
180 console.log(
181 `% improvement over ${calls} calls (global time):`,
182 (100 * (wFGT - jWGT)) / wFGT,
183 );
184
185 console.log(
186 `% improvement over ${calls} calls (processing time):`,
187 (100 * (wFPT - jWPT)) / wFPT,
188 );
189}

Callers 1

test.jsFile · 0.85

Calls 6

profileFunction · 0.85
testWorkerFarmFunction · 0.85
profileEndFunction · 0.85
testJestWorkerFunction · 0.85
sleepFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected