Search in sources :

Example 1 with CounterNode

use of jcog.tree.rtree.util.CounterNode in project narchy by automenta.

the class RTreeNDTest method treeSearchStatsTest.

/**
 * Do a search and collect stats on how many nodes we hit and how many
 * bounding boxes we had to evaluate to get all the results.
 * <p>
 * Preliminary findings:
 * - Evals for QUADRATIC tree increases with size of the search bounding box.
 * - QUADRATIC seems to be ideal for small search bounding boxes.
 */
@Disabled
public // This test ignored because output needs to be manually evaluated.
void treeSearchStatsTest() {
    final int entryCount = 5000;
    final RectDouble2D[] rects = generateRandomRects(entryCount);
    for (int j = 0; j < 6; j++) {
        for (Spatialization.DefaultSplits type : Spatialization.DefaultSplits.values()) {
            RTree<RectDouble2D> rTree = createRectDouble2DTree(2, 12, type);
            for (int i = 0; i < rects.length; i++) {
                rTree.add(rects[i]);
            }
            rTree.instrumentTree();
            final RectDouble2D searchRect = new RectDouble2D(100, 100, 120, 120);
            RectDouble2D[] results = new RectDouble2D[entryCount];
            final long start = System.nanoTime();
            int foundCount = rTree.containedToArray(searchRect, results);
            final long end = System.nanoTime() - start;
            CounterNode<RectDouble2D> root = (CounterNode<RectDouble2D>) rTree.root();
            // System.out.println("[" + type + "] searched " + root.containingCount + " nodes, returning " + foundCount + " entries");
            System.out.println("[" + type + "] evaluated " + CounterNode.bboxEvalCount + " b-boxes, returning " + foundCount + " entries");
            System.out.println("Run was " + end / 1000 + " us");
        }
    }
}
Also used : RectDouble2D(jcog.tree.rtree.rect.RectDouble2D) CounterNode(jcog.tree.rtree.util.CounterNode) Disabled(org.junit.jupiter.api.Disabled)

Example 2 with CounterNode

use of jcog.tree.rtree.util.CounterNode in project narchy by automenta.

the class RTree2DTest method treeSearchStatsTest.

/**
 * Do a search and collect stats on how many nodes we hit and how many
 * bounding boxes we had to evaluate to get all the results.
 *
 * Preliminary findings:
 *  - Evals for QUADRATIC tree increases with size of the search bounding box.
 *  - QUADRATIC seems to be ideal for small search bounding boxes.
 */
@Disabled
public // This test ignored because output needs to be manually evaluated.
void treeSearchStatsTest() {
    final int entryCount = 5000;
    final RectDouble2D[] rects = generateRandomRects(entryCount);
    for (Spatialization.DefaultSplits type : Spatialization.DefaultSplits.values()) {
        RTree<RectDouble2D> rTree = createRect2DTree(2, 8, type);
        for (int i = 0; i < rects.length; i++) {
            rTree.add(rects[i]);
        }
        rTree.instrumentTree();
        final RectDouble2D searchRect = new RectDouble2D(100, 100, 120, 120);
        RectDouble2D[] results = new RectDouble2D[entryCount];
        int foundCount = rTree.containedToArray(searchRect, results);
        CounterNode<RectDouble2D> root = (CounterNode<RectDouble2D>) rTree.root();
        System.out.println("[" + type + "] searched " + CounterNode.searchCount + " nodes, returning " + foundCount + " entries");
        System.out.println("[" + type + "] evaluated " + CounterNode.bboxEvalCount + " b-boxes, returning " + foundCount + " entries");
    }
}
Also used : RectDouble2D(jcog.tree.rtree.rect.RectDouble2D) CounterNode(jcog.tree.rtree.util.CounterNode) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

RectDouble2D (jcog.tree.rtree.rect.RectDouble2D)2 CounterNode (jcog.tree.rtree.util.CounterNode)2 Disabled (org.junit.jupiter.api.Disabled)2