From b677847ccab60c8f00abe4955137643248ac4a0b Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 10 Jun 2020 09:29:49 +0200 Subject: [PATCH] teach reporter about the new rtcm total distance measure, and report quantiles --- reporter.cc | 86 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/reporter.cc b/reporter.cc index b607cbb..5395dc7 100644 --- a/reporter.cc +++ b/reporter.cc @@ -14,6 +14,46 @@ using namespace std; extern const char* g_gitHash; +class Stats +{ +public: + void add(double v) + { + results.dirty=true; + results.d.push_back(v); + } + struct Results + { + vector d; + bool dirty{false}; + double median() const + { + return quantile(0.5); + } + double quantile(double p) const + { + unsigned int pos = p * d.size(); + if(!d.size()) + throw runtime_error("Empty range for quantile"); + if(pos == d.size()) + --pos; + return d[p*d.size()]; + } + + }; + const Results& done() + { + if(results.dirty) { + sort(results.d.begin(), results.d.end()); + results.dirty=false; + } + return results; + } + +private: + Results results; +}; + /* Goal: generate statistics from influxdb. @@ -40,6 +80,7 @@ struct IntervalStat std::optional sisa; bool ripe{false}; bool expired{false}; + double rtcmDist{-1}; }; @@ -145,14 +186,36 @@ int main(int argc, char **argv) } } } + + ///////////////////// + + res = mc.getURL(url + mc.urlEncode("select mean(\"total-dist\") from \"rtcm-eph-correction\" where "+period+" and sigid='"+to_string(sigid)+"' group by gnssid,sv,sigid,time(10m)")); + j = nlohmann::json::parse(res); + for(const auto& sv : j["results"][0]["series"]) { + try { + const auto& tags=sv["tags"]; + SatID id{(unsigned int)std::stoi((string)tags["gnssid"]), (unsigned int)std::stoi((string)tags["sv"]), (unsigned int)std::stoi((string)tags["sigid"])}; + for(const auto& v : sv["values"]) { + + g_stats[id][(int)v[0]].rtcmDist = v[1]; + } + } + catch(...) { + continue; + } + } + + ///////////////////// + + g_stats.erase({2,14,1}); g_stats.erase({2,18,1}); g_stats.erase({2,14,5}); g_stats.erase({2,18,5}); - + /* g_stats[{2,19,1}]; - + */ unsigned int maxintervals=0; time_t start=time(0), stop=0; for(const auto& sv : g_stats) { @@ -171,10 +234,19 @@ int main(int argc, char **argv) int totnapa=0, totunhealthy=0, tothealthy=0, tottesting=0; int totunobserved=0; int totripe = 0, totexpired = 0; + Stats totRTCM; for(const auto& sv : g_stats) { int napa=0, unhealthy=0, healthy=0, testing=0, ripe=0, expired=0; + + Stats rtcm; for(const auto& i : sv.second) { + + if(i.second.rtcmDist >= 0) { + rtcm.add(i.second.rtcmDist); + totRTCM.add(i.second.rtcmDist); + } + if(i.second.ripe) ripe++; if(i.second.expired) @@ -209,7 +281,7 @@ int main(int argc, char **argv) totexpired += expired; totunobserved += maxintervals-sv.second.size(); - cout<