public class IntervalStoreTest
{
+
+ public static void main(String[] args)
+ {
+ new IntervalStoreTest().defaultTests();
+ }
+
+ private void defaultTests()
+ {
+ testAddAndQueryTiming();
+ }
+
@Test(groups = "Functional")
public void testFindOverlaps_nonNested()
{
@Test(groups = "Timing")
public void testAddAndQueryTiming()
{
- IntervalStoreI<SimpleFeature> 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<SimpleFeature> 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);
}
/**
*
* @param store
*/
- private void testAddAndQueryTiming(IntervalStoreI<SimpleFeature> store)
+ private void testAddAndQueryTiming(IntervalStoreI<SimpleFeature> 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
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");
}
}