jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1499657 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
Date Thu, 04 Jul 2013 05:37:02 GMT
Author: chetanm
Date: Thu Jul  4 05:37:02 2013
New Revision: 1499657

URL: http://svn.apache.org/r1499657
Log:
OAK-863 - Enable stats for various caches used in Oak by default

Prettyfying toString

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java?rev=1499657&r1=1499656&r2=1499657&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/CacheStats.java
Thu Jul  4 05:37:02 2013
@@ -18,7 +18,10 @@
  */
 package org.apache.jackrabbit.oak.cache;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import com.google.common.base.Objects;
 import com.google.common.cache.Cache;
@@ -148,8 +151,8 @@ public class CacheStats implements Cache
                 .add("loadCount", getLoadCount())
                 .add("loadSuccessCount", getLoadSuccessCount())
                 .add("loadExceptionCount", getLoadExceptionCount())
-                .add("totalLoadTime", getTotalLoadTime())
-                .add("averageLoadPenalty", String.format("%1.2f", getAverageLoadPenalty()))
+                .add("totalLoadTime", timeInWords(getTotalLoadTime()))
+                .add("averageLoadPenalty (nanos)", getAverageLoadPenalty())
                 .add("evictionCount", getEvictionCount())
                 .add("elementCount", getElementCount())
                 .add("totalWeight", humanReadableByteCount(estimateCurrentWeight(), true))
@@ -165,6 +168,16 @@ public class CacheStats implements Cache
         return cache.stats().minus(lastSnapshot);
     }
 
+    private static String timeInWords(long nanos){
+        long millis = TimeUnit.NANOSECONDS.toMillis(nanos);
+        return String.format("%d min, %d sec",
+                TimeUnit.MILLISECONDS.toMinutes(millis),
+                TimeUnit.MILLISECONDS.toSeconds(millis) -
+                        TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))
+        );
+        //return (new SimpleDateFormat("mm:ss:SSS")).format(new Date(millis));
+    }
+
     /**
      * Based on http://stackoverflow.com/a/3758880/1035417
      */



Mime
View raw message