From d77624ea12f4b7123a85e0537682a9257f63c15c Mon Sep 17 00:00:00 2001 From: hansonr Date: Sun, 22 Sep 2019 07:31:18 -0400 Subject: [PATCH] test update --- test/intervalstore/nonc/IntervalStoreTest.java | 88 +++++++++++++++++++----- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/test/intervalstore/nonc/IntervalStoreTest.java b/test/intervalstore/nonc/IntervalStoreTest.java index 7c1a921..e21976a 100644 --- a/test/intervalstore/nonc/IntervalStoreTest.java +++ b/test/intervalstore/nonc/IntervalStoreTest.java @@ -46,6 +46,17 @@ import intervalstore.api.IntervalStoreI; public class IntervalStoreTest { + + public static void main(String[] args) + { + new IntervalStoreTest().defaultTests(); + } + + private void defaultTests() + { + testAddAndQueryTiming(); + } + @Test(groups = "Functional") public void testFindOverlaps_nonNested() { @@ -592,13 +603,32 @@ public class IntervalStoreTest @Test(groups = "Timing") public void testAddAndQueryTiming() { - IntervalStoreI store = new intervalstore.impl.IntervalStore<>(); - System.out.println("IntervalStoreJ"); - testAddAndQueryTiming(store); + testAddAndQuery(1, 20000000, 10, 20); + testAddAndQuery(0, 0, 10, 20); + + testAddAndQuery(1, 20000000, 10, 200); + testAddAndQuery(0, 0, 10, 200); + + testAddAndQuery(1, 20000000, 10, 2000); + testAddAndQuery(0, 0, 10, 2000); + + testAddAndQuery(1, 20000000, -2000000, 2000000); + testAddAndQuery(0, 0, -2000000, 2000000); + } - System.out.println("\nnonc.IntervalStore"); + private void testAddAndQuery(int addstart, int addend, int start, int end) + { + System.out.println("\nadd: " + addstart + " " + addend + " query: " + + start + " " + end); + StringBuffer sb = new StringBuffer(); + IntervalStoreI store; store = new intervalstore.nonc.IntervalStore<>(); - testAddAndQueryTiming(store); + testAddAndQueryTiming(store, false, sb, addstart, addend, start, end); + + store = new intervalstore.impl.IntervalStore<>(); + testAddAndQueryTiming(store, true, sb, addstart, addend, start, end); + + System.out.println(sb); } /** @@ -608,30 +638,44 @@ public class IntervalStoreTest * * @param store */ - private void testAddAndQueryTiming(IntervalStoreI store) + private void testAddAndQueryTiming(IntervalStoreI store, + boolean isNCList, StringBuffer sb, int addstart, int addend, + int start, int end) { final int seqlen = 100000; // e.g. length of gene sequence final int repeats = 20; final int K = 1000; final int warmups = 5; - final int[] scales = new int[] { 10 * K, 100 * K, K * K }; + final int[] scales = new int[] { 10 * K, 100 * K, 1000 * K };// , 10000 * K + // }; Random r = new Random(732); // fixed seed = repeatable test int counter = 0; // to ensure a distinct description for each feature - System.out.println("Scale\titeration\tmicrosecs"); + // System.out.println("Scale\titeration\tmicrosecs"); for (int scale : scales) { /* * add 'scale' features to the store */ + long ntimeLoad = System.nanoTime(); for (int i = 0; i < scale; i++) { - SimpleFeature sf = makeFeature(seqlen, r, counter); + SimpleFeature sf; + sf = makeFeature(seqlen, r, counter); counter++; store.add(sf); } + if (!isNCList) + { + ((intervalstore.nonc.IntervalStore) store).revalidate(); + } + String line = "time to load " + (isNCList ? "NClist " : "NCArray ") + + (System.nanoTime() - ntimeLoad) / K / K + " ms scale " + + scale; + // System.out.println(line); + sb.append(line); /* * do "add then query" and log the time taken for the query @@ -640,20 +684,32 @@ public class IntervalStoreTest long total = 0L; for (int i = 0; i < repeats + warmups; i++) { - SimpleFeature sf = makeFeature(seqlen, r, counter); - store.add(sf); + SimpleFeature sf; + if (addstart == 0) + { + sf = makeFeature(seqlen, r, counter++); + } + else + { + sf = new SimpleFeature(addstart, addend, "desc" + counter++); + } + System.gc(); long t1 = System.nanoTime(); - store.findOverlaps(10, 20); + store.add(sf); + store.findOverlaps(start, end); long elapsed = System.nanoTime() - t1; if (i >= warmups) { total += elapsed; - System.out.println( - String.format("%d\t%d\t%d", scale, i - warmups, - elapsed / K)); + // System.out.println( + // String.format("%d\t%d\t%d", scale, i - warmups, + // elapsed / K)); } } - System.out.println("average " + (total / (K * repeats))); + sb.append( + " add+query " + + (isNCList ? "NCList " : "NCArray ") + + (total / (K * repeats)) + " microseconds\n"); } } -- 1.7.10.2