aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/com/jogamp/common/os/Platform.java4
-rw-r--r--src/java/com/jogamp/common/util/ReflectionUtil.java5
-rw-r--r--src/junit/com/jogamp/common/util/IntIntHashMapTest.java25
-rw-r--r--src/junit/com/jogamp/common/util/LongIntHashMapTest.java25
-rw-r--r--src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java10
5 files changed, 39 insertions, 30 deletions
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index 9c65596..ffea42c 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -540,11 +540,11 @@ public class Platform extends PlatformPropsImpl {
}
private static long getCurrentSleepJitterImpl(final long nsDuration, final int splitInLoops) {
final long nsPeriod = nsDuration / splitInLoops;
- final long t0_ns = System.nanoTime();
+ final long t0_ns = Clock.currentNanos();
for(int i=splitInLoops; i>0; i--) {
try { TimeUnit.NANOSECONDS.sleep(nsPeriod); } catch (final InterruptedException e) { }
}
- return ( ( System.nanoTime() - t0_ns ) - nsDuration ) / splitInLoops;
+ return ( ( Clock.currentNanos() - t0_ns ) - nsDuration ) / splitInLoops;
}
}
diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java
index 0d76827..27ca983 100644
--- a/src/java/com/jogamp/common/util/ReflectionUtil.java
+++ b/src/java/com/jogamp/common/util/ReflectionUtil.java
@@ -51,6 +51,7 @@ import jogamp.common.Debug;
import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.os.Clock;
public final class ReflectionUtil {
@@ -125,9 +126,9 @@ public final class ReflectionUtil {
private static Class<?> getClassImpl(final String clazzName, final boolean initializeClazz, final ClassLoader cl) throws ClassNotFoundException {
if(DEBUG_STATS_FORNAME) {
- final long t0 = System.nanoTime();
+ final long t0 = Clock.currentNanos();
final Class<?> res = Class.forName(clazzName, initializeClazz, cl);
- final long t1 = System.nanoTime();
+ final long t1 = Clock.currentNanos();
final long nanoCosts = t1 - t0;
synchronized(forNameLock) {
forNameCount++;
diff --git a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java
index dc523f0..647e471 100644
--- a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java
+++ b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java
@@ -39,6 +39,7 @@ import java.util.Map.Entry;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.os.Platform;
import com.jogamp.junit.util.SingletonJunitCase;
@@ -254,54 +255,54 @@ public class IntIntHashMapTest extends SingletonJunitCase {
" warmup: " + warmup);
out.println("put");
- long time = nanoTime();
+ long time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
intmap.put(pairs.keys[i], pairs.values[i]);
}
- final long intmapPutTime = (nanoTime() - time);
+ final long intmapPutTime = (Clock.currentNanos() - time);
out.println(" iimap: " + intmapPutTime/1000000.0f+"ms");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
map.put(pairs.keys[i], pairs.values[i]);
}
- final long mapPutTime = (nanoTime() - time);
+ final long mapPutTime = (Clock.currentNanos() - time);
out.println(" map: " + mapPutTime/1000000.0f+"ms");
System.out.println();
System.out.println("get");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
intmap.get(pairs.keys[i]);
}
- final long intmapGetTime = (nanoTime() - time);
+ final long intmapGetTime = (Clock.currentNanos() - time);
out.println(" iimap: " + intmapGetTime/1000000.0f+"ms");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
map.get(pairs.keys[i]);
}
- final long mapGetTime = (nanoTime() - time);
+ final long mapGetTime = (Clock.currentNanos() - time);
out.println(" map: " + mapGetTime/1000000.0f+"ms");
out.println();
out.println("remove");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
intmap.remove(pairs.keys[i]);
}
assertEquals(0, intmap.size());
- final long intmapRemoveTime = (nanoTime() - time);
+ final long intmapRemoveTime = (Clock.currentNanos() - time);
out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
map.remove(pairs.keys[i]);
}
assertEquals(0, map.size());
- final long mapRemoveTime = (nanoTime() - time);
+ final long mapRemoveTime = (Clock.currentNanos() - time);
out.println(" map: " + mapRemoveTime/1000000.0f+"ms");
if(!warmup) {
diff --git a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java
index 9ea4206..60f404d 100644
--- a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java
+++ b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java
@@ -39,6 +39,7 @@ import java.util.Map.Entry;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.os.Platform;
import com.jogamp.junit.util.SingletonJunitCase;
@@ -143,55 +144,55 @@ public class LongIntHashMapTest extends SingletonJunitCase {
" warmup: " + warmup);
out.println("put");
- long time = nanoTime();
+ long time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
intmap.put(pairs.keys[i], pairs.values[i]);
}
- final long intmapPutTime = (nanoTime() - time);
+ final long intmapPutTime = (Clock.currentNanos() - time);
out.println(" iimap: " + intmapPutTime/1000000.0f+"ms");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
map.put(pairs.keys[i], pairs.values[i]);
}
- final long mapPutTime = (nanoTime() - time);
+ final long mapPutTime = (Clock.currentNanos() - time);
out.println(" map: " + mapPutTime/1000000.0f+"ms");
System.out.println();
System.out.println("get");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
intmap.get(pairs.keys[i]);
}
- final long intmapGetTime = (nanoTime() - time);
+ final long intmapGetTime = (Clock.currentNanos() - time);
out.println(" iimap: " + intmapGetTime/1000000.0f+"ms");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
map.get(pairs.keys[i]);
}
- final long mapGetTime = (nanoTime() - time);
+ final long mapGetTime = (Clock.currentNanos() - time);
out.println(" map: " + mapGetTime/1000000.0f+"ms");
out.println();
out.println("remove");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
intmap.remove(pairs.keys[i]);
}
assertEquals(0, intmap.size());
- final long intmapRemoveTime = (nanoTime() - time);
+ final long intmapRemoveTime = (Clock.currentNanos() - time);
out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms");
- time = nanoTime();
+ time = Clock.currentNanos();
for (int i = 0; i < iterations; i++) {
map.remove(pairs.keys[i]);
}
assertEquals(0, map.size());
- final long mapRemoveTime = (nanoTime() - time);
+ final long mapRemoveTime = (Clock.currentNanos() - time);
out.println(" map: " + mapRemoveTime/1000000.0f+"ms");
if(!warmup) {
diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java
index e5456f4..e119569 100644
--- a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java
+++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java
@@ -37,6 +37,7 @@ import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.junit.util.SingletonJunitCase;
@@ -141,6 +142,7 @@ public class TestRecursiveLock01 extends SingletonJunitCase {
incrDeferredThreadCount();
}
+ @Override
public void run() {
if(DEBUG) {
System.err.print("[a2");
@@ -175,9 +177,9 @@ public class TestRecursiveLock01 extends SingletonJunitCase {
}
public final void lock() {
- long td = System.nanoTime();
+ long td = Clock.currentNanos();
locker.lock();
- td = System.nanoTime() - td;
+ td = Clock.currentNanos() - td;
final String cur = Thread.currentThread().getName();
ThreadStat ts = threadWaitMap.get(cur);
@@ -258,14 +260,17 @@ public class TestRecursiveLock01 extends SingletonJunitCase {
this.yieldMode = yieldMode;
}
+ @Override
public final void stop() {
shouldStop = true;
}
+ @Override
public final boolean isStopped() {
return stopped;
}
+ @Override
public void waitUntilStopped() {
synchronized(this) {
while(!stopped) {
@@ -279,6 +284,7 @@ public class TestRecursiveLock01 extends SingletonJunitCase {
}
+ @Override
public void run() {
synchronized(this) {
while(!shouldStop && loops>0) {