MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / _getAndResetLoadEstimate

Method _getAndResetLoadEstimate

lib/load.js:54–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52 }
53
54 _getAndResetLoadEstimate() {
55 debug(`LoadEstimator._getAndResetLoadEstimate(): jobType = ${this.jobType}`);
56 this._addIntegratedLoad();
57 const nowMS = Date.now();
58 const deltaSeconds = Math.max(1, nowMS - this.lastEstimateTimeMS) / 1000;
59 const loadEstimate = this.integratedLoad / deltaSeconds;
60
61 // reset stats
62 this.lastEstimateTimeMS = nowMS;
63 this.lastIncrementTimeMS = nowMS;
64 this.integratedLoad = 0;
65
66 return loadEstimate;
67 }
68
69 _addIntegratedLoad() {
70 debug(`LoadEstimator._addIntegratedLoad(): jobType = ${this.jobType}`);

Callers 1

_reportLoadMethod · 0.95

Calls 2

_addIntegratedLoadMethod · 0.95
debugFunction · 0.85

Tested by

no test coverage detected