From a9edfc573b49cd1c494dbe8dca919632ab8571bb Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 10 Jan 2019 22:40:49 +0100 Subject: [PATCH] dnsscope miscounted its statistics, assigning '101 usec' to the <100 usec bin. Secondly, it neglected to process the last latency bin, causing it to spuriously report very late packets. --- pdns/dnsscope.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pdns/dnsscope.cc b/pdns/dnsscope.cc index 8e46b4b785..82a36acad9 100644 --- a/pdns/dnsscope.cc +++ b/pdns/dnsscope.cc @@ -458,9 +458,8 @@ try sum=0; double lastperc=0, perc=0; uint64_t lastsum=0; - for(cumul_t::const_iterator i=cumul.begin(); i!=cumul.end(); ++i) { - sum+=i->second; + for(cumul_t::const_iterator i=cumul.begin(); i!=cumul.end(); ++i) { for(done_t::iterator j=done.begin(); j!=done.end(); ++j) { if(!j->second && i->first > j->first) { j->second=true; @@ -476,7 +475,24 @@ try lastsum=sum; } } + sum+=i->second; + } + + for(auto j = done.begin(); j != done.end(); ++j) { + if(!j->second) { + perc=sum*100.0/totpairs; + if(j->first < 1024) + cout<< perc <<"% of questions answered within " << j->first << " usec ("; + else + cout<< perc <<"% of questions answered within " << j->first/1000.0 << " msec ("; + + cout<first/1000000.0) <<" seconds"<