Permalink
Browse files

fix up latency reporting for sub-millisecond latencies (would clip to 0)

  • Loading branch information...
1 parent d45c1f1 commit 0678b251c464f1809746ac5848b08c21ed368beb @ahupowerdns ahupowerdns committed with mind04 Dec 11, 2014
Showing with 3 additions and 3 deletions.
  1. +3 −3 pdns/common_startup.cc
@@ -179,8 +179,9 @@ static uint64_t getSysUserTimeMsec(const std::string& str)
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
- if(str=="sys-msec")
+ if(str=="sys-msec") {
return (ru.ru_stime.tv_sec*1000ULL + ru.ru_stime.tv_usec/1000);
+ }
else
return (ru.ru_utime.tv_sec*1000ULL + ru.ru_utime.tv_usec/1000);
@@ -287,8 +288,7 @@ void sendout(const AnswerData<DNSPacket> &AD)
N->send(AD.A);
int diff=AD.A->d_dt.udiff();
- avg_latency=(int)(1023*avg_latency/1024+diff/1024);
-
+ avg_latency=(int)(0.999*avg_latency+0.001*diff);
delete AD.A;
}

0 comments on commit 0678b25

Please sign in to comment.