You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ja...@apache.org on 2015/06/29 09:00:34 UTC

[13/50] [abbrv] git commit: updated refs/heads/dhcpoffload to 45721ae

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 <wr...@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/dhcpoffload
Commit: 78c802a539e3446dee351efdbdb678cf91f8729e
Parents: c0a1009
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Mon Jun 22 14:07:33 2015 +0200
Committer: wilderrodrigues <wr...@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