zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvfangmin <...@git.apache.org>
Subject [GitHub] zookeeper pull request #629: ZOOKEEPER-2641:AvgRequestLatency metric improve...
Date Tue, 25 Sep 2018 23:03:39 GMT
Github user lvfangmin commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/629#discussion_r220382358
  
    --- Diff: src/java/main/org/apache/zookeeper/server/ServerStats.java ---
    @@ -53,10 +54,13 @@ public ServerStats(Provider provider) {
         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;
    +            //be account to four decimal places
    +            double avgLatency = totalLatency / (double)count;
    +            BigDecimal bg = new BigDecimal(avgLatency);
    --- End diff --
    
    This is accurate, but not sure how heavy it is and will it affect the performance or not.
But I think we're not calling this a lot, so it should be fine.


---

Mime
View raw message