(name, seconds, intervalSeconds, tracked, options)
| 244 | } |
| 245 | |
| 246 | async function collectPhase(name, seconds, intervalSeconds, tracked, options) { |
| 247 | const samples = []; |
| 248 | let currentTracked = tracked; |
| 249 | const totalSamples = sampleCount(seconds, intervalSeconds); |
| 250 | |
| 251 | for (let index = 0; index < totalSamples; index += 1) { |
| 252 | const sample = buildSample(readProcesses(), currentTracked, options); |
| 253 | currentTracked = sample.tracked; |
| 254 | samples.push(sample); |
| 255 | |
| 256 | const newPidSummary = |
| 257 | sample.newPids.length > 0 ? ` new:${sample.newPids.join(",")}` : ""; |
| 258 | |
| 259 | console.log( |
| 260 | `${name} ${index + 1}/${totalSamples} cap=${formatMb(sample.capTotalKb)} ws=${formatMb(sample.windowServerTotalKb)} media=${formatMb(sample.mediaTotalKb)} total=${formatMb(sample.grandTotalKb)}${newPidSummary}`, |
| 261 | ); |
| 262 | console.log(` ${renderTopProcesses(sample)}`); |
| 263 | |
| 264 | if (index < totalSamples - 1) { |
| 265 | await sleep(intervalSeconds * 1000); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | return { |
| 270 | samples, |
| 271 | settled: pickSettledSample(samples, options.trailingSamples), |
| 272 | tracked: currentTracked, |
| 273 | }; |
| 274 | } |
| 275 | |
| 276 | function restoreStore(path, originalStoreContents) { |
| 277 | writeFileSync(path, originalStoreContents); |
no test coverage detected