Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/pm2/node_modules/tx2/src/utils/probes/ drwxr-xr-x | |
| Viewing file: Select action/file-type:
var units = require('./units');
module.exports = ExponentiallyWeightedMovingAverage;
function ExponentiallyWeightedMovingAverage(timePeriod, tickInterval) {
this._timePeriod = timePeriod || 1 * units.MINUTE;
this._tickInterval = tickInterval || ExponentiallyWeightedMovingAverage.TICK_INTERVAL;
this._alpha = 1 - Math.exp(-this._tickInterval / this._timePeriod);
this._count = 0;
this._rate = 0;
};
ExponentiallyWeightedMovingAverage.TICK_INTERVAL = 5 * units.SECONDS;
ExponentiallyWeightedMovingAverage.prototype.update = function(n) {
this._count += n;
};
ExponentiallyWeightedMovingAverage.prototype.tick = function() {
var instantRate = this._count / this._tickInterval;
this._count = 0;
this._rate += (this._alpha * (instantRate - this._rate));
};
ExponentiallyWeightedMovingAverage.prototype.rate = function(timeUnit) {
return (this._rate || 0) * timeUnit;
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0769 ]-- |