MCPcopy
hub / github.com/browserless/browserless / sample

Method sample

src/monitoring.ts:392–408  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

390 }
391
392 protected async sample(): Promise<void> {
393 const { cpu, memory } = await this.statsSource.read();
394
395 if (cpu !== null) {
396 // statsSource returns 0-1 fraction; smoothed value is stored as 0-100 percent.
397 const current = cpu * 100;
398 const alpha = this.config.getCpuEmaAlpha();
399 this.smoothedCpu =
400 this.smoothedCpu === null
401 ? current
402 : alpha * current + (1 - alpha) * this.smoothedCpu;
403 }
404
405 if (memory !== null) {
406 this.cachedMemory = memory;
407 }
408 }
409
410 public async getMachineStats(): Promise<IResourceLoad> {
411 return this.statsSource.read();

Callers 2

constructorMethod · 0.95
runSampleMethod · 0.80

Calls 2

getCpuEmaAlphaMethod · 0.80
readMethod · 0.65

Tested by 1

runSampleMethod · 0.64