summaryrefslogtreecommitdiff
path: root/test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java
diff options
context:
space:
mode:
authorErich Schubert <erich@debian.org>2013-10-29 20:02:37 +0100
committerAndrej Shadura <andrewsh@debian.org>2019-03-09 22:30:37 +0000
commitec7f409f6e795bbcc6f3c005687954e9475c600c (patch)
treefbf36c0ab791c556198b487ca40ae56ae5ab1ee5 /test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java
parent974d4cf6d54cadc06258039f2cd0515cc34aeac6 (diff)
parent8300861dc4c62c5567a4e654976072f854217544 (diff)
Import Debian changes 0.6.0~beta2-1
elki (0.6.0~beta2-1) unstable; urgency=low * New upstream beta release. * 3DPC extension is not yet included.
Diffstat (limited to 'test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java')
-rw-r--r--test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java35
1 files changed, 19 insertions, 16 deletions
diff --git a/test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java b/test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java
index 084a3761..f80fbec5 100644
--- a/test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java
+++ b/test/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/TestHeapPerformance.java
@@ -42,16 +42,18 @@ import org.junit.Test;
* @author Erich Schubert
*/
public class TestHeapPerformance {
- final private int queueSize = 100000;
+ final private int queueSize = 200000;
- final private int iterations = 20;
+ final private int preiterations = 20;
+
+ final private int iterations = 200;
final private long seed = 123456L;
@Test
public void testRuntime() throws Exception {
// prepare the data set
- final List<Integer> elements = new ArrayList<Integer>(queueSize);
+ final List<Integer> elements = new ArrayList<>(queueSize);
{
final Random random = new Random(seed);
for(int i = 0; i < queueSize; i++) {
@@ -62,39 +64,40 @@ public class TestHeapPerformance {
// Pretest, to trigger hotspot compiler, hopefully.
{
- for(int j = 0; j < iterations; j++) {
- Heap<Integer> pq = new Heap<Integer>();
+ for(int j = 0; j < preiterations; j++) {
+ ComparableMinHeap<Integer> pq = new ComparableMinHeap<>();
testHeap(elements, pq);
}
- for(int j = 0; j < iterations; j++) {
- PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); // 11,
+ for(int j = 0; j < preiterations; j++) {
+ PriorityQueue<Integer> pq = new PriorityQueue<>();
testQueue(elements, pq);
}
}
- long hstart = System.nanoTime();
+ long pqstart = System.nanoTime();
{
for(int j = 0; j < iterations; j++) {
- Heap<Integer> pq = new Heap<Integer>();
- testHeap(elements, pq);
+ PriorityQueue<Integer> pq = new PriorityQueue<>();
+ testQueue(elements, pq);
}
}
- long htime = System.nanoTime() - hstart;
+ long pqtime = System.nanoTime() - pqstart;
- long pqstart = System.nanoTime();
+ long hstart = System.nanoTime();
{
for(int j = 0; j < iterations; j++) {
- PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); // 11
- testQueue(elements, pq);
+ ComparableMinHeap<Integer> pq = new ComparableMinHeap<>();
+ testHeap(elements, pq);
}
}
- long pqtime = System.nanoTime() - pqstart;
+ long htime = System.nanoTime() - hstart;
+
System.err.println("Heap performance test: us: " + htime*1E-9 + " java: " + pqtime*1E-9);
assertTrue("Heap performance regression - run test individually, since the hotspot optimizations may make the difference! " + htime + " >>= " + pqtime, htime < 1.05 * pqtime);
// 1.05 allows some difference in measuring
}
- private void testHeap(final List<Integer> elements, Heap<Integer> pq) {
+ private void testHeap(final List<Integer> elements, ComparableMinHeap<Integer> pq) {
// Insert all
for(int i = 0; i < elements.size(); i++) {
pq.add(elements.get(i));