changeset 117:65b09f85aee3

Merge Global into Loop, simplify Loop interface.
author shade
date Sat, 17 Aug 2013 13:21:15 +0400
parents e5450f2db884
children c859389d08d6
files jmh-core/src/main/java/org/openjdk/jmh/logic/Global.java jmh-core/src/main/java/org/openjdk/jmh/logic/Loop.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java jmh-core/src/test/java/org/openjdk/jmh/logic/TestLoop.java
diffstat 5 files changed, 64 insertions(+), 374 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/logic/Global.java	Fri Aug 16 18:39:06 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.jmh.logic;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class Global extends GlobalL4 {
-
-    public Global(int threads, boolean syncIterations) {
-        super(threads, syncIterations);
-    }
-
-}
-
-class GlobalL1 {
-    public int p01, p02, p03, p04, p05, p06, p07, p08;
-    public int p11, p12, p13, p14, p15, p16, p17, p18;
-    public int p21, p22, p23, p24, p25, p26, p27, p28;
-    public int p31, p32, p33, p34, p35, p36, p37, p38;
-}
-
-/**
- * @see BlackHole for rationale
- */
-class GlobalL2 extends GlobalL1 {
-    public final int threads;
-    public final boolean syncIterations;
-
-    public final AtomicInteger warmupVisited, warmdownVisited;
-    public volatile boolean warmupShouldWait, warmdownShouldWait;
-
-    public GlobalL2(int threads, boolean syncIterations) {
-        this.threads = threads;
-        this.syncIterations = syncIterations;
-        this.warmupVisited = new AtomicInteger();
-        this.warmdownVisited = new AtomicInteger();
-
-        warmupShouldWait = syncIterations;
-        warmdownShouldWait = syncIterations;
-    }
-
-    public void announceWarmupReady() {
-        if (!syncIterations) return;
-        int v = warmupVisited.incrementAndGet();
-        if (v == threads) {
-            warmupShouldWait = false;
-        }
-
-        if (v > threads) {
-            throw new IllegalStateException("More threads than expected");
-        }
-    }
-
-    public void announceWarmdownReady() {
-        if (!syncIterations) return;
-        int v = warmdownVisited.incrementAndGet();
-        if (v == threads) {
-            warmdownShouldWait = false;
-        }
-
-        if (v > threads) {
-            throw new IllegalStateException("More threads than expected");
-        }
-    }
-}
-
-class GlobalL3 extends GlobalL2 {
-    public int e01, e02, e03, e04, e05, e06, e07, e08;
-    public int e11, e12, e13, e14, e15, e16, e17, e18;
-    public int e21, e22, e23, e24, e25, e26, e27, e28;
-    public int e31, e32, e33, e34, e35, e36, e37, e38;
-
-    public GlobalL3(int threads, boolean syncIterations) {
-        super(threads, syncIterations);
-    }
-}
-
-class GlobalL4 extends GlobalL3 {
-    public int marker;
-
-    public GlobalL4(int threads, boolean syncIterations) {
-        super(threads, syncIterations);
-    }
-
-}
--- a/jmh-core/src/main/java/org/openjdk/jmh/logic/Loop.java	Fri Aug 16 18:39:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/logic/Loop.java	Sat Aug 17 13:21:15 2013 +0400
@@ -31,6 +31,7 @@
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * The Loop logic class. Controls if we should iterate another lap in the benchmark loop via calls to done();
@@ -51,40 +52,10 @@
         }
     });
 
-    /**
-     * Constructor
-     *
-     * @param duration How long we should loop
-     */
-    public Loop(long duration) {
-        this(new TimeValue(duration, TimeUnit.MILLISECONDS));
+    public Loop(int threads, boolean syncIterations, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
+        super(threads, syncIterations, loopTime, preSetup, preTearDown, lastIteration, timeUnit);
     }
 
-    /**
-     * Constructor
-     *
-     * @param loopTime How long we should loop
-     */
-    public Loop(TimeValue loopTime) {
-        this(null, loopTime, null, null, false, null);
-    }
-
-    public Loop(Global global, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
-        super(global, loopTime, preSetup, preTearDown, lastIteration, timeUnit);
-    }
-
-
-    /** Start timer and record start time */
-    @Deprecated // GMB generator emits the proper code instead
-    public void start() {
-        enable();
-
-        assert start == 0;
-        assert end == 0;
-        start = System.nanoTime();
-    }
-
-
     public void enable() {
         assert !isDone;
         isDone = false;
@@ -98,82 +69,6 @@
     }
 
     /**
-     * Temporary pause the timing measurement, does NOT affect the iteration time for the loop completion
-     * <p/>
-     * To continue timing call resume()
-     */
-    @Deprecated // GMB generator emits the proper code instead
-    public void pauseMeasurement() {
-        assert pauseStart == 0;
-        pauseStart = System.nanoTime();
-    }
-
-    /** Resume a paused timing */
-    @Deprecated // GMB generator emits the proper code instead
-    public void resumeMeasurement() {
-        assert pauseStart != 0;
-        totalPause += System.nanoTime() - pauseStart;
-        pauseStart = 0;
-    }
-
-    /** End timer and record the end time */
-    @Deprecated // GMB generator emits the proper code instead
-    public void end() {
-        assert isDone;
-        end = System.nanoTime();
-    }
-
-    /**
-     * Check if the timed duration has been completed
-     *
-     * @return if we are done
-     */
-    @Deprecated // GMB generator emits the proper code instead
-    public boolean done() {
-        assert start != 0;
-        return isDone;
-    }
-
-    /**
-     * The measured time a benchmark iteration took in nanoseconds
-     * <p/>
-     * If the measurement was paused and resumed during the benchmark the time spent between these calls are deducted
-     * from the iteration time
-     *
-     * @return the time the iteration took
-     */
-    public long getTime() {
-        assert start != 0;
-        assert end != 0;
-        assert isDone;
-        return (end - start - totalPause);
-    }
-
-    /**
-     * Get the total time spent with paused timing
-     *
-     * @return The total pause time in nanoseconds
-     */
-    public long getTotalPausetime() {
-        assert start != 0;
-        assert end != 0;
-        assert isDone;
-        return totalPause;
-    }
-
-    /**
-     * Get the total time an iteration took without including any pauses
-     *
-     * @return The total iteration run time including pauses in nanoseconds
-     */
-    public long getTotalRuntime() {
-        assert start != 0;
-        assert end != 0;
-        assert isDone;
-        return (end - start);
-    }
-
-    /**
      * returns requested loop duration in milliseconds.
      * the primary purpose of the method - integration tests.
      * @return
@@ -241,31 +136,56 @@
 
     /** How long we should loop */
     public final long duration;
-    /** Start timestamp */
-    public long start;
-    /** End timestamp */
-    public long end;
-    /** Start of pause */
-    public long pauseStart;
-    /** Total pause time */
-    public long totalPause;
 
     public final CountDownLatch preSetup;
     public final CountDownLatch preTearDown;
     public final boolean lastIteration;
+    public final TimeUnit timeUnit;
+    public final int threads;
+    public final boolean syncIterations;
 
-    public final Global global;
+    public final AtomicInteger warmupVisited, warmdownVisited;
+    public volatile boolean warmupShouldWait, warmdownShouldWait;
 
-    public final TimeUnit timeUnit;
+    public LoopL2(int threads, boolean syncIterations, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
+        this.threads = threads;
+        this.syncIterations = syncIterations;
+        this.warmupVisited = new AtomicInteger();
+        this.warmdownVisited = new AtomicInteger();
 
-    public LoopL2(Global global, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
+        warmupShouldWait = syncIterations;
+        warmdownShouldWait = syncIterations;
         this.preSetup = preSetup;
         this.preTearDown = preTearDown;
         this.duration = loopTime.convertTo(TimeUnit.NANOSECONDS);
         this.lastIteration = lastIteration;
         this.timeUnit = timeUnit;
-        this.global = global;
     }
+
+    public void announceWarmupReady() {
+        if (!syncIterations) return;
+        int v = warmupVisited.incrementAndGet();
+        if (v == threads) {
+            warmupShouldWait = false;
+        }
+
+        if (v > threads) {
+            throw new IllegalStateException("More threads than expected");
+        }
+    }
+
+    public void announceWarmdownReady() {
+        if (!syncIterations) return;
+        int v = warmdownVisited.incrementAndGet();
+        if (v == threads) {
+            warmdownShouldWait = false;
+        }
+
+        if (v > threads) {
+            throw new IllegalStateException("More threads than expected");
+        }
+    }
+
 }
 
 class LoopL3 extends LoopL2 {
@@ -274,16 +194,16 @@
     public int e21, e22, e23, e24, e25, e26, e27, e28;
     public int e31, e32, e33, e34, e35, e36, e37, e38;
 
-    public LoopL3(Global global, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
-        super(global, loopTime, preSetup, preTearDown, lastIteration, timeUnit);
+    public LoopL3(int threads, boolean syncIterations, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
+        super(threads, syncIterations, loopTime, preSetup, preTearDown, lastIteration, timeUnit);
     }
 }
 
 class LoopL4 extends LoopL3 {
     public int marker;
 
-    public LoopL4(Global global, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
-        super(global, loopTime, preSetup, preTearDown, lastIteration, timeUnit);
+    public LoopL4(int threads, boolean syncIterations, TimeValue loopTime, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, TimeUnit timeUnit) {
+        super(threads, syncIterations, loopTime, preSetup, preTearDown, lastIteration, timeUnit);
     }
 }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Fri Aug 16 18:39:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Sat Aug 17 13:21:15 2013 +0400
@@ -38,7 +38,6 @@
 import org.openjdk.jmh.annotations.Threads;
 import org.openjdk.jmh.annotations.Warmup;
 import org.openjdk.jmh.logic.BlackHole;
-import org.openjdk.jmh.logic.Global;
 import org.openjdk.jmh.logic.Loop;
 import org.openjdk.jmh.logic.results.AverageTimePerOp;
 import org.openjdk.jmh.logic.results.OpsPerTimeUnit;
@@ -422,7 +421,6 @@
         writer.println("import " + Generated.class.getName() + ';');
         writer.println();
         writer.println("import " + Loop.class.getName() + ';');
-        writer.println("import " + Global.class.getName() + ';');
         writer.println("import " + BlackHole.class.getName() + ';');
         writer.println("import " + Result.class.getName() + ';');
         writer.println("import " + OpsPerTimeUnit.class.getName() + ';');
@@ -700,10 +698,10 @@
             iterationProlog(writer, 3, method, states);
 
             // synchronize iterations prolog: announce ready
-            writer.println(ident(3) + "global.announceWarmupReady();");
+            writer.println(ident(3) + "loop.announceWarmupReady();");
 
             // synchronize iterations prolog: catchup loop
-            writer.println(ident(3) + "while (global.warmupShouldWait) {");
+            writer.println(ident(3) + "while (loop.warmupShouldWait) {");
 
             invocationProlog(writer, 4, method, states, false);
             writer.println(ident(4) + emitCall(method, states) + ';');
@@ -719,7 +717,6 @@
             }
 
             // measurement loop call
-            writer.println(ident(3) + "loop.enable();");
             writer.println(ident(3) + "RawResultPair res = " + method.getSimpleName() + "_" + benchmarkKind + "_measurementLoop(loop, " + states.getImplicit("bench").toLocal() + ", " + states.getImplicit("blackhole").toLocal() + prefix(states.getArgList(method)) + ");");
 
             // control objects get a special treatment
@@ -728,10 +725,10 @@
             }
 
             // synchronize iterations epilog: announce ready
-            writer.println(ident(3) + "global.announceWarmdownReady();");
+            writer.println(ident(3) + "loop.announceWarmdownReady();");
 
             // synchronize iterations epilog: catchup loop
-            writer.println(ident(3) + "while (global.warmdownShouldWait) {");
+            writer.println(ident(3) + "while (loop.warmdownShouldWait) {");
 
             invocationProlog(writer, 4, method, states, false);
             writer.println(ident(4) + emitCall(method, states) + ';');
@@ -790,10 +787,10 @@
             iterationProlog(writer, 3, method, states);
 
             // synchronize iterations prolog: announce ready
-            writer.println(ident(3) + "global.announceWarmupReady();");
+            writer.println(ident(3) + "loop.announceWarmupReady();");
 
             // synchronize iterations prolog: catchup loop
-            writer.println(ident(3) + "while (global.warmupShouldWait) {");
+            writer.println(ident(3) + "while (loop.warmupShouldWait) {");
 
             invocationProlog(writer, 4, method, states, false);
             writer.println(ident(4) + emitCall(method, states) + ';');
@@ -809,7 +806,6 @@
             }
 
             // measurement loop call
-            writer.println(ident(3) + "loop.enable();");
             writer.println(ident(3) + "RawResultPair res = " + method.getSimpleName() + "_" + benchmarkKind + "_measurementLoop(loop, " + states.getImplicit("bench").toLocal() + ", " + states.getImplicit("blackhole").toLocal() + prefix(states.getArgList(method)) + ");");
 
             // control objects get a special treatment
@@ -818,10 +814,10 @@
             }
 
             // synchronize iterations epilog: announce ready
-            writer.println(ident(3) + "global.announceWarmdownReady();");
+            writer.println(ident(3) + "loop.announceWarmdownReady();");
 
             // synchronize iterations epilog: catchup loop
-            writer.println(ident(3) + "while (global.warmdownShouldWait) {");
+            writer.println(ident(3) + "while (loop.warmdownShouldWait) {");
 
             invocationProlog(writer, 4, method, states, false);
             writer.println(ident(4) + emitCall(method, states) + ';');
@@ -870,8 +866,6 @@
         writer.println(ident(2) + "int groupId = threadId / groupThreadCount;");
         writer.println(ident(2) + "int siblingId = threadId % groupThreadCount;");
         writer.println();
-        writer.println(ident(2) + "Global global = loop.global;");
-        writer.println();
     }
 
     private String prefix(String argList) {
@@ -901,10 +895,10 @@
             iterationProlog(writer, 3, method, states);
 
             // synchronize iterations prolog: announce ready
-            writer.println(ident(3) + "global.announceWarmupReady();");
+            writer.println(ident(3) + "loop.announceWarmupReady();");
 
             // synchronize iterations prolog: catchup loop
-            writer.println(ident(3) + "while (global.warmupShouldWait) {");
+            writer.println(ident(3) + "while (loop.warmupShouldWait) {");
 
             invocationProlog(writer, 4, method, states, false);
             writer.println(ident(4) + emitCall(method, states) + ';');
@@ -928,10 +922,10 @@
             }
 
             // synchronize iterations epilog: announce ready
-            writer.println(ident(3) + "global.announceWarmdownReady();");
+            writer.println(ident(3) + "loop.announceWarmdownReady();");
 
             // synchronize iterations epilog: catchup loop
-            writer.println(ident(3) + "while (global.warmdownShouldWait) {");
+            writer.println(ident(3) + "while (loop.warmdownShouldWait) {");
 
             invocationProlog(writer, 4, method, states, false);
             writer.println(ident(4) + emitCall(method, states) + ';');
@@ -957,7 +951,6 @@
             writer.println("        long rnd = System.nanoTime();");
             writer.println("        long rndMask = 1;");
             writer.println("        long time = 0;");
-            writer.println("        loop.enable();");
             writer.println("        do {");
 
             invocationProlog(writer, 4, method, states, true);
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java	Fri Aug 16 18:39:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java	Sat Aug 17 13:21:15 2013 +0400
@@ -26,7 +26,6 @@
 
 
 import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.logic.Global;
 import org.openjdk.jmh.logic.Loop;
 import org.openjdk.jmh.logic.results.IterationData;
 import org.openjdk.jmh.logic.results.Result;
@@ -92,13 +91,14 @@
         CountDownLatch preSetupBarrier = new CountDownLatch(numThreads);
         CountDownLatch preTearDownBarrier = new CountDownLatch(numThreads);
 
-        Global global = new Global(numThreads, shouldSynchIterations);
+        IterationData iterationResults = new IterationData(microbenchmark, numThreads, runtime);
 
-        IterationData iterationResults = new IterationData(microbenchmark, numThreads, runtime);
+        Loop loop = new Loop(numThreads, shouldSynchIterations, runtime, preSetupBarrier, preTearDownBarrier, last, timeUnit);
 
         BenchmarkTask[] runners = new BenchmarkTask[numThreads];
         for (int i = 0; i < runners.length; i++) {
-            runners[i] = new BenchmarkTask(threadLocal, new Loop(global, runtime, preSetupBarrier, preTearDownBarrier, last, timeUnit));
+
+            runners[i] = new BenchmarkTask(threadLocal, loop);
         }
 
         // submit tasks to threadpool
@@ -115,6 +115,8 @@
         }
         startProfilers();
 
+        loop.enable();
+
         // wait for all threads to stop executing
         try {
             preTearDownBarrier.await();
@@ -204,13 +206,13 @@
 
                 if (shouldSynchIterations) {
                     try {
-                        loop.global.announceWarmupReady();
+                        loop.announceWarmupReady();
                     } catch (Exception e1) {
                         // more threads than expected
                     }
 
                     try {
-                        loop.global.announceWarmdownReady();
+                        loop.announceWarmdownReady();
                     } catch (Exception e1) {
                         // more threads than expected
                     }
--- a/jmh-core/src/test/java/org/openjdk/jmh/logic/TestLoop.java	Fri Aug 16 18:39:06 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.jmh.logic;
-
-import org.junit.Test;
-import org.openjdk.jmh.runner.parameters.TimeValue;
-
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for Loop
- *
- * @author anders.astrand@oracle.com, staffan.friberg@oracle.com
- *
- */
-public class TestLoop {
-
-    @Test
-    public void testDone() {
-        long time = 1000;
-
-        Loop loop = new Loop(time);
-        loop.start();
-        while (!loop.done()) {
-            try {
-                Thread.sleep(50);
-            } catch (InterruptedException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        loop.end();
-
-        // getTime() is in ns
-        // Allow 50ms diff since sleep is inaccurate depending on system used
-        assertEquals("Actual loop time differ from specified time", time, loop.getTime() / (1000000.0), 80);
-    }
-
-    @Test
-    public void testPauseResume() {
-        long time = 1000;
-        boolean pause = false;
-        Loop loop = new Loop(time);
-        loop.start();
-        while (!loop.done()) {
-            try {
-                if (pause) {
-                    loop.pauseMeasurement();
-                    Thread.sleep(50);
-                    loop.resumeMeasurement();
-                } else {
-                    Thread.sleep(50);
-                }
-                pause = !pause;
-            } catch (InterruptedException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        loop.end();
-
-        // getTime() is in ns
-        // Allow 50ms diff since sleep is inaccurate depending on system used
-        assertEquals("Actual loop time differ from specified time", time / 2, loop.getTime() / (1000000.0), 80);
-    }
-
-    @Test
-    public void testTimeUnitConvert() {
-        long time = 100000;
-
-        Loop loop = new Loop(new TimeValue(time, TimeUnit.MICROSECONDS));
-        loop.start();
-        while (!loop.done()) {
-            try {
-                Thread.sleep(50);
-            } catch (InterruptedException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        loop.end();
-
-        // getTime() is in ns
-        // Allow 50ms diff since sleep is inaccurate depending on system used
-        assertEquals("Actual loop time differ from specified time", time, loop.getTime() / (1000.0), 80000);
-    }
-
-    @Test
-    public void testDuration() {
-        assertEquals(0, new Loop(new TimeValue(1, TimeUnit.MICROSECONDS)).getDuration());
-        assertEquals(TimeUnit.NANOSECONDS.convert(1,TimeUnit.MICROSECONDS), new Loop(new TimeValue(1, TimeUnit.MICROSECONDS)).getDuration(TimeUnit.NANOSECONDS));
-        assertEquals(TimeUnit.MILLISECONDS.convert(1,TimeUnit.SECONDS), new Loop(new TimeValue(1, TimeUnit.SECONDS)).getDuration());
-        assertEquals(17, new Loop(new TimeValue(17, TimeUnit.NANOSECONDS)).getDuration(TimeUnit.NANOSECONDS));
-        assertEquals(42, new Loop(42).getDuration());
-        assertEquals(42000000, new Loop(42).getDuration(TimeUnit.NANOSECONDS));
-    }
-}