You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/04/01 01:15:33 UTC

svn commit: r1087487 - /tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JSCompressor.java

Author: hlship
Date: Thu Mar 31 23:15:32 2011
New Revision: 1087487

URL: http://svn.apache.org/viewvc?rev=1087487&view=rev
Log:
TAP5-73: Refactor the execution time logging

Modified:
    tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JSCompressor.java

Modified: tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JSCompressor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JSCompressor.java?rev=1087487&r1=1087486&r2=1087487&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JSCompressor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JSCompressor.java Thu Mar 31 23:15:32 2011
@@ -42,6 +42,8 @@ import com.yahoo.platform.yui.compressor
  */
 public class JSCompressor implements ResourceMinimizer
 {
+    private static final double NANOS_TO_MILLIS = 1.0d / 1000000.0d;
+
     private final Logger logger;
 
     private final OperationTracker tracker;
@@ -113,16 +115,20 @@ public class JSCompressor implements Res
         inputStream.close();
         writer.close();
 
-        long ellapsedNanos = System.nanoTime() - startNanos;
-
         // The content is minimized, but can still be (GZip) compressed.
 
-        StreamableResource output = new StreamableResourceImpl(input.getContentType(),
-                CompressionStatus.COMPRESSABLE, input.getLastModified(), new BytestreamCache(bos));
+        StreamableResource output = new StreamableResourceImpl(input.getContentType(), CompressionStatus.COMPRESSABLE,
+                input.getLastModified(), new BytestreamCache(bos));
+
+        long elapsedNanos = System.nanoTime() - startNanos;
 
         if (logger.isDebugEnabled())
-            logger.debug(String.format("Minimized %,d input bytes to %,d output bytes in %.2d ms", input.getSize(),
-                    output.getSize(), ellapsedNanos / 1000.));
+        {
+            double elapsedMillis = ((double) elapsedNanos) * NANOS_TO_MILLIS;
+
+            logger.debug(String.format("Minimized %,d input bytes to %,d output bytes in %.2f ms", input.getSize(),
+                    output.getSize(), elapsedMillis));
+        }
 
         return output;
     }