zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eolivelli <...@git.apache.org>
Subject [GitHub] zookeeper pull request #629: ZOOKEEPER-2641:AvgRequestLatency metric improve...
Date Sun, 16 Sep 2018 17:11:09 GMT
Github user eolivelli commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/629#discussion_r217921254
  
    --- Diff: src/java/main/org/apache/zookeeper/server/ServerStats.java ---
    @@ -54,9 +57,10 @@ synchronized public long getMinLatency() {
             return minLatency == Long.MAX_VALUE ? 0 : minLatency;
         }
     
    -    synchronized public long getAvgLatency() {
    +    synchronized public double getAvgLatency() {
             if (count != 0) {
    -            return totalLatency / count;
    +            String avgLatency = df.format((double)totalLatency / count);
    +            return Double.parseDouble(avgLatency);
    --- End diff --
    
    The conversion you are doing does not force a given number of digits
    
    You should perform the division and the return a string fornatted with a max number of
decimal digits.
    
    Or you can calculate the value as integer with some trick
    Like
    return ( totalLatency *100 / count) / 100.0


---

Mime
View raw message