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:48 UTC
[27/50] [abbrv] git commit: updated refs/heads/dhcpoffload to 45721ae
Renaming a couple of varibale to avoid misunderstanding
- All "micro" references have been replaced with "nano"
Signed-off-by: Daan Hoogland <da...@onecht.net>
This closes #516
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cbf5155f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cbf5155f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cbf5155f
Branch: refs/heads/dhcpoffload
Commit: cbf5155f7b89d032c092c95e4dd507e927cf37a0
Parents: 2f14537
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Tue Jun 23 22:46:19 2015 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Wed Jun 24 09:36:41 2015 +0200
----------------------------------------------------------------------
utils/src/com/cloud/utils/Profiler.java | 4 ++--
utils/test/com/cloud/utils/TestProfiler.java | 13 +++++++++----
2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbf5155f/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 5977453..f8e44bd 100644
--- a/utils/src/com/cloud/utils/Profiler.java
+++ b/utils/src/com/cloud/utils/Profiler.java
@@ -46,8 +46,8 @@ public class Profiler {
*/
public long getDuration() {
if (startTickNanoSeconds != null && stopTickNanoSeconds != null) {
- final long timeInMicroSeconds = stopTickNanoSeconds - startTickNanoSeconds;
- return timeInMicroSeconds;
+ final long timeInNanoSeconds = stopTickNanoSeconds - startTickNanoSeconds;
+ return timeInNanoSeconds;
}
return -1;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbf5155f/utils/test/com/cloud/utils/TestProfiler.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/TestProfiler.java b/utils/test/com/cloud/utils/TestProfiler.java
index d801059..6861f06 100644
--- a/utils/test/com/cloud/utils/TestProfiler.java
+++ b/utils/test/com/cloud/utils/TestProfiler.java
@@ -28,6 +28,7 @@ import com.cloud.utils.testcase.Log4jEnabledTestCase;
public class TestProfiler extends Log4jEnabledTestCase {
protected final static Logger s_logger = Logger.getLogger(TestProfiler.class);
+ private static final long ONE_SECOND = 1000l;
private static final long MILLIS_FACTOR = 1000l;
private static final int MARGIN = 100;
private static final double EXPONENT = 3d;
@@ -39,13 +40,13 @@ public class TestProfiler extends Log4jEnabledTestCase {
final Profiler pf = new Profiler();
pf.start();
try {
- Thread.sleep(MILLIS_FACTOR);
+ Thread.sleep(ONE_SECOND);
} catch (final InterruptedException e) {
}
pf.stop();
final long durationInMillis = pf.getDurationInMillis();
- s_logger.info("Duration : " + durationInMillis);
+ s_logger.info("Duration in Millis: " + durationInMillis);
// An error margin in order to cover the time taken by the star/stop calls.
// 100 milliseconds margin seems too much, but it will avoid assertion error
@@ -56,16 +57,17 @@ public class TestProfiler extends Log4jEnabledTestCase {
}
@Test
- public void testProfilerInMicro() {
+ public void testProfilerInNano() {
final Profiler pf = new Profiler();
pf.start();
try {
- Thread.sleep(MILLIS_FACTOR);
+ Thread.sleep(ONE_SECOND);
} catch (final InterruptedException e) {
}
pf.stop();
final long duration = pf.getDuration();
+ s_logger.info("Duration in Nano: " + duration);
Assert.assertTrue(duration >= Math.pow(MILLIS_FACTOR, EXPONENT));
}
@@ -101,6 +103,9 @@ public class TestProfiler extends Log4jEnabledTestCase {
long nanoTime2 = 0l;
nanoTime1 = System.nanoTime();
nanoTime2 = System.nanoTime();
+
+ // Using sysout here because is faster than the logger and we don't want to
+ // waste time.
System.out.println("Nano time 1: " + nanoTime1);
System.out.println("Nano time 2: " + nanoTime2);