From 96036791b5da288171ca919ebd7fbfa53d8e0fce Mon Sep 17 00:00:00 2001 From: wellenvogel Date: Sat, 11 Dec 2021 20:31:36 +0100 Subject: [PATCH] intermediate: change statistics --- lib/statistics/GwStatistics.h | 32 ++++++++++++++++++-------------- src/main.cpp | 1 - 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/statistics/GwStatistics.h b/lib/statistics/GwStatistics.h index aa5a6ec..fc84f45 100644 --- a/lib/statistics/GwStatistics.h +++ b/lib/statistics/GwStatistics.h @@ -40,10 +40,12 @@ class TimeAverage{ class TimeMonitor{ public: TimeAverage **times=NULL; + unsigned long *current=NULL; unsigned long start=0; unsigned long lastLog=0; unsigned long lastLogCount=0; unsigned long count=0; + unsigned long max=0; size_t len; TimeMonitor(size_t len,double factor=0.3){ this->len=len; @@ -51,22 +53,16 @@ class TimeMonitor{ for (size_t i=0;igetCurrent() == 0) continue; - if (times[i]->getCurrent() > rt) rt=times[i]->getCurrent(); - } - return rt; - } String getLog(){ unsigned long now=millis(); String log; @@ -75,13 +71,14 @@ class TimeMonitor{ unsigned long tdif=now-lastLog; if (tdif > 0){ log+=String((double)(num*1000)/(double)tdif); - log+="/s,"; - log+=String(getMax()); - log+="ms#"; + log+="/s["; + log+=String(max); + log+="ms]#"; } } lastLog=now; - lastLogCount=count; + lastLogCount=count; + max=0; for (size_t i=1;igetCount()){ log+=String(i); @@ -99,7 +96,14 @@ class TimeMonitor{ } void setTime(size_t index){ if (index < 1 || index >= len) return; - unsigned long current=millis()-start; - times[index-1]->add(current); + unsigned long sv=start; + for (size_t i=0;i max) max=now-start; + times[index-1]->add(currentv); } }; diff --git a/src/main.cpp b/src/main.cpp index d051c7b..eb6204f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -402,7 +402,6 @@ public: protected: virtual void processRequest() { - int numPgns = nmea0183Converter->numPgns(); GwJsonDocument status(256 + countNMEA2KIn.getJsonSize()+ countNMEA2KOut.getJsonSize() +