/*
 * Copyright 2016 higherfrequencytrading.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.chronicle.core.time;

import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.onoes.ExceptionKey;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by peter on 08/12/16.
 */
public class SystemTimeProviderTest {
    @Test
    public void currentTimeMicros() throws Exception {
        Jvm.recordExceptions(true);
        TimeProvider tp = SystemTimeProvider.INSTANCE;
        long start = System.currentTimeMillis();
        while (System.currentTimeMillis() < start + 10000) {
            long time2 = tp.currentTimeMicros();
            Thread.yield();
        }
        Map<ExceptionKey, Integer> exceptions = new HashMap<>();
        Jvm.dumpException(exceptions);
        System.out.println(exceptions);
    }
}
@@ -657,164 +657,68 @@
 ort 
-net.openhft.chronicle.core.Jvm;%0Aimport net.openhft.chronicle.core.onoes.ExceptionKey;%0Aimport org.junit.Test;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map
+org.junit.Test;%0A%0Aimport static org.junit.Assert.assertEquals
 ;%0A%0A/
@@ -864,44 +864,8 @@
 n %7B%0A
-        Jvm.recordExceptions(true);%0A
     
@@ -960,24 +960,102 @@
 meMillis();%0A
+        long minDiff = Long.MAX_VALUE;%0A        long maxDiff = Long.MIN_VALUE;%0A
         whil
@@ -1098,11 +1098,9 @@
 t + 
-100
+5
 00) 
@@ -1166,22 +1166,52 @@
     
-Thread.yield()
+long now = System.currentTimeMillis() * 1000
 ;%0A  
@@ -1220,151 +1220,324 @@
     
-%7D%0A
     
-    Map%3CExceptionKey, Integer%3E exceptions = new HashMap%3C%3E();%0A        Jvm.dumpException(exceptions);%0A        System.out.println(exceptions
+long diff = time2 - now;%0A            if (minDiff %3E diff) minDiff = diff;%0A            if (maxDiff %3C diff) maxDiff = diff;%0A            Thread.yield();%0A        %7D%0A        System.out.println(%22minDiff: %22 + minDiff + %22, maxDiff: %22 + maxDiff);%0A        assertEquals(minDiff, 0, 50);%0A        assertEquals(maxDiff, 1000, 50
 );%0A 

Add currentTimeMicros()