cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [2/2] git commit: updated refs/heads/master to f29bf1e
Date Tue, 23 Jun 2015 08:03:44 GMT
Replace System.currentTimeMillis() by System.nanoTime()

   - System.nanoTime() is the best way to measure elapsed time in Java.
   - It gives a resolution on the order of microseconds

The System.currentTimeMillis() is used when calculating absolut time.

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/78c802a5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/78c802a5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/78c802a5

Branch: refs/heads/master
Commit: 78c802a539e3446dee351efdbdb678cf91f8729e
Parents: c0a1009
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Mon Jun 22 14:07:33 2015 +0200
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Tue Jun 23 10:03:20 2015 +0200

----------------------------------------------------------------------
 utils/src/com/cloud/utils/Profiler.java | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78c802a5/utils/src/com/cloud/utils/Profiler.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/Profiler.java b/utils/src/com/cloud/utils/Profiler.java
index e75da0e..6082a92 100644
--- a/utils/src/com/cloud/utils/Profiler.java
+++ b/utils/src/com/cloud/utils/Profiler.java
@@ -23,24 +23,20 @@ public class Profiler {
     private Long startTickInMs;
     private Long stopTickInMs;
 
-    public Profiler() {
-        startTickInMs = null;
-        stopTickInMs = null;
-    }
-
     public long start() {
-        startTickInMs = System.currentTimeMillis();
+        startTickInMs = System.nanoTime();
         return startTickInMs.longValue();
     }
 
     public long stop() {
-        stopTickInMs = System.currentTimeMillis();
+        stopTickInMs = System.nanoTime();
         return stopTickInMs.longValue();
     }
 
     public long getDuration() {
-        if (startTickInMs != null && stopTickInMs != null)
+        if (startTickInMs != null && stopTickInMs != null) {
             return stopTickInMs.longValue() - startTickInMs.longValue();
+        }
 
         return -1;
     }
@@ -55,12 +51,14 @@ public class Profiler {
 
     @Override
     public String toString() {
-        if (startTickInMs == null)
+        if (startTickInMs == null) {
             return "Not Started";
+        }
 
-        if (stopTickInMs == null)
+        if (stopTickInMs == null) {
             return "Started but not stopped";
+        }
 
         return "Done. Duration: " + getDuration() + "ms";
     }
-}
+}
\ No newline at end of file


Mime
View raw message