averaging fixed

This commit is contained in:
Wolfgang Hottgenroth
2017-08-25 18:13:10 +02:00
parent 3309ba29e5
commit 21f7f02a63
2 changed files with 10 additions and 6 deletions

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const log = require("./log");
const CallChain = require("./callchain");
const Processor = require("./processor");
const CHECK_PERIOD = 10; // seconds
const CHECK_PERIOD = 60; // seconds
class ClientEntry {
}
class MissingEventProcessor extends Processor.AProcessor {
@ -28,7 +28,9 @@ class MissingEventProcessor extends Processor.AProcessor {
clientEntry.delay = currentTime - clientEntry.lastEvent;
clientEntry.lastEvent = currentTime;
clientEntry.count += 1;
clientEntry.delaySum += clientEntry.delay;
if (clientEntry.count >= 1) {
clientEntry.delaySum += clientEntry.delay;
}
clientEntry.avgDelay = clientEntry.delaySum / clientEntry.count;
this.clientMap.set(client, clientEntry);
log.info(`Entry for ${client} updated`);
@ -38,7 +40,7 @@ class MissingEventProcessor extends Processor.AProcessor {
clientEntry.client = client;
clientEntry.lastEvent = currentTime;
clientEntry.delay = 0;
clientEntry.count = 0;
clientEntry.count = -1;
clientEntry.delaySum = 0;
clientEntry.avgDelay = 0;
this.clientMap.set(client, clientEntry);

View File

@ -3,7 +3,7 @@ import * as CallChain from './callchain'
import * as Processor from './processor'
const CHECK_PERIOD : number = 10 // seconds
const CHECK_PERIOD : number = 60 // seconds
class ClientEntry {
client : string
@ -39,7 +39,9 @@ class MissingEventProcessor extends Processor.AProcessor {
clientEntry.delay = currentTime - clientEntry.lastEvent
clientEntry.lastEvent = currentTime
clientEntry.count += 1
clientEntry.delaySum += clientEntry.delay
if (clientEntry.count >= 1) {
clientEntry.delaySum += clientEntry.delay
}
clientEntry.avgDelay = clientEntry.delaySum / clientEntry.count
this.clientMap.set(client, clientEntry)
log.info(`Entry for ${client} updated`)
@ -48,7 +50,7 @@ class MissingEventProcessor extends Processor.AProcessor {
clientEntry.client = client
clientEntry.lastEvent = currentTime
clientEntry.delay = 0
clientEntry.count = 0
clientEntry.count = -1
clientEntry.delaySum = 0
clientEntry.avgDelay = 0
this.clientMap.set(client, clientEntry)