jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r995116 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
Date Wed, 08 Sep 2010 16:25:35 GMT
Author: jukka
Date: Wed Sep  8 16:25:34 2010
New Revision: 995116

URL: http://svn.apache.org/viewvc?rev=995116&view=rev
Log:
JCR-2741: Improved logging for session operations

Automatically switch to microseconds for performance reporting when milliseconds are too coarse.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java?rev=995116&r1=995115&r2=995116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java
Wed Sep  8 16:25:34 2010
@@ -50,6 +50,11 @@ public class SessionState {
         LoggerFactory.getLogger(SessionState.class);
 
     /**
+     * Number of nanoseconds in a microsecond.
+     */
+    private static final int NS_PER_US = 1000;
+
+    /**
      * Number of nanoseconds in a millisecond.
      */
     private static final int NS_PER_MS = 1000000;
@@ -170,9 +175,14 @@ public class SessionState {
                         try {
                             return operation.perform(context);
                         } finally {
-                            log.debug("It took {}ms to perform {}",
-                                    (System.nanoTime() - start) / NS_PER_MS,
-                                    operation);
+                            long time = System.nanoTime() - start;
+                            if (time > NS_PER_MS) {
+                                log.debug("Performed {} in {}ms",
+                                        operation, time / NS_PER_MS);
+                            } else {
+                                log.debug("Performed {} in {}us",
+                                        operation, time / NS_PER_US);
+                            }
                         }
                     } else {
                         return operation.perform(context);



Mime
View raw message