summaryrefslogtreecommitdiffstats
path: root/test/junit/com/jogamp/common
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-27 23:13:19 +0200
committerMichael Bien <[email protected]>2010-04-27 23:13:19 +0200
commitfcb2cae956ce4f0ec44c8cbc81be0f588f472f03 (patch)
treec5ec87f6e8d06e6bbd8ac7b0ac15074a41ae8106 /test/junit/com/jogamp/common
parenta9b91a40a88b305765b35c40c4a1d65b27980cfe (diff)
switched to nanoTime() and moved asserts to end of the benchmark.
Diffstat (limited to 'test/junit/com/jogamp/common')
-rw-r--r--test/junit/com/jogamp/common/util/IntIntHashMapTest.java35
-rw-r--r--test/junit/com/jogamp/common/util/LongIntHashMapTest.java37
2 files changed, 35 insertions, 37 deletions
diff --git a/test/junit/com/jogamp/common/util/IntIntHashMapTest.java b/test/junit/com/jogamp/common/util/IntIntHashMapTest.java
index f041123..bc02947 100644
--- a/test/junit/com/jogamp/common/util/IntIntHashMapTest.java
+++ b/test/junit/com/jogamp/common/util/IntIntHashMapTest.java
@@ -113,55 +113,54 @@ public class IntIntHashMapTest {
out.println(intmap.getClass().getName()+" vs "+map.getClass().getName());
out.println("put");
- long time = currentTimeMillis();
+ long time = nanoTime();
for (int i = 0; i < iterations; i++) {
intmap.put(rndKeys[i], rndValues[i]);
}
- long intmapTime = (currentTimeMillis() - time);
- out.println(" iimap: " + intmapTime+"ms");
+ long intmapPutTime = (nanoTime() - time);
+ out.println(" iimap: " + intmapPutTime/1000000.0f+"ms");
- time = currentTimeMillis();
+ time = nanoTime();
for (int i = 0; i < iterations; i++) {
map.put(rndKeys[i], rndValues[i]);
}
- long mapTime = (currentTimeMillis() - time);
- out.println(" map: " + mapTime+"ms");
-
- assertTrue(intmapTime <= mapTime);
+ long mapPutTime = (nanoTime() - time);
+ out.println(" map: " + mapPutTime/1000000.0f+"ms");
System.out.println();
System.out.println("get");
- intmapTime = (currentTimeMillis() - time);
- out.println(" iimap: " + intmapTime+"ms");
+ long intmapGetTime = (nanoTime() - time);
+ out.println(" iimap: " + intmapGetTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
intmap.get(rndValues[i]);
}
- mapTime = (currentTimeMillis() - time);
- out.println(" map: " + mapTime+"ms");
+ long mapGetTime = (nanoTime() - time);
+ out.println(" map: " + mapGetTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
map.get(rndValues[i]);
}
- assertTrue(intmapTime <= mapTime);
out.println();
out.println("remove");
- intmapTime = (currentTimeMillis() - time);
- out.println(" iimap: " + intmapTime+"ms");
+ long intmapRemoveTime = (nanoTime() - time);
+ out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
intmap.remove(rndValues[i]);
}
- mapTime = (currentTimeMillis() - time);
- out.println(" map: " + mapTime+"ms");
+ long mapRemoveTime = (nanoTime() - time);
+ out.println(" map: " + mapRemoveTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
map.remove(rndValues[i]);
}
- assertTrue(intmapTime <= mapTime);
+ assertTrue("'put' to slow", intmapPutTime <= mapPutTime);
+ assertTrue("'get' to slow", intmapGetTime <= mapGetTime);
+ assertTrue("'remove' to slow", intmapRemoveTime <= mapRemoveTime);
}
diff --git a/test/junit/com/jogamp/common/util/LongIntHashMapTest.java b/test/junit/com/jogamp/common/util/LongIntHashMapTest.java
index 53aa252..b51211c 100644
--- a/test/junit/com/jogamp/common/util/LongIntHashMapTest.java
+++ b/test/junit/com/jogamp/common/util/LongIntHashMapTest.java
@@ -113,55 +113,54 @@ public class LongIntHashMapTest {
out.println(intmap.getClass().getName()+" vs "+map.getClass().getName());
out.println("put");
- long time = currentTimeMillis();
+ long time = nanoTime();
for (int i = 0; i < iterations; i++) {
intmap.put(rndKeys[i], rndValues[i]);
}
- long intmapTime = (currentTimeMillis() - time);
- out.println(" limap: " + intmapTime+"ms");
+ long intmapPutTime = (nanoTime() - time);
+ out.println(" iimap: " + intmapPutTime/1000000.0f+"ms");
- time = currentTimeMillis();
+ time = nanoTime();
for (int i = 0; i < iterations; i++) {
map.put(rndKeys[i], rndValues[i]);
}
- long mapTime = (currentTimeMillis() - time);
- out.println(" map: " + mapTime+"ms");
-
- assertTrue(intmapTime <= mapTime);
+ long mapPutTime = (nanoTime() - time);
+ out.println(" map: " + mapPutTime/1000000.0f+"ms");
System.out.println();
System.out.println("get");
- intmapTime = (currentTimeMillis() - time);
- out.println(" limap: " + intmapTime+"ms");
+ long intmapGetTime = (nanoTime() - time);
+ out.println(" iimap: " + intmapGetTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
intmap.get(rndValues[i]);
}
-
- mapTime = (currentTimeMillis() - time);
- out.println(" map: " + mapTime+"ms");
+
+ long mapGetTime = (nanoTime() - time);
+ out.println(" map: " + mapGetTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
map.get(rndValues[i]);
}
- assertTrue(intmapTime <= mapTime);
out.println();
out.println("remove");
- intmapTime = (currentTimeMillis() - time);
- out.println(" limap: " + intmapTime+"ms");
+ long intmapRemoveTime = (nanoTime() - time);
+ out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
intmap.remove(rndValues[i]);
}
- mapTime = (currentTimeMillis() - time);
- out.println(" map: " + mapTime+"ms");
+ long mapRemoveTime = (nanoTime() - time);
+ out.println(" map: " + mapRemoveTime/1000000.0f+"ms");
for (int i = 0; i < iterations; i++) {
map.remove(rndValues[i]);
}
- assertTrue(intmapTime <= mapTime);
+ assertTrue("'put' to slow", intmapPutTime <= mapPutTime);
+ assertTrue("'get' to slow", intmapGetTime <= mapGetTime);
+ assertTrue("'remove' to slow", intmapRemoveTime <= mapRemoveTime);
}