Search in sources :

Example 21 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class VoronoiPerfTest method run.

public void run(final int nPts) {
    final List pts = randomPoints(nPts);
    final Stopwatch sw = new Stopwatch();
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
    builder.insertVertices(pts);
    final Geometry g = builder.getEdges();
// System.out.println("# pts: " + pts.size() + " -- " +
// sw.getTimeString());
// System.out.println(g);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder) Stopwatch(com.revolsys.geometry.util.Stopwatch) List(java.util.List) ArrayList(java.util.ArrayList)

Example 22 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class PerformanceTestRunner method runInternal.

private void runInternal(final Class clz) {
    try {
        final Constructor ctor = clz.getConstructor(String.class);
        final PerformanceTestCase test = (PerformanceTestCase) ctor.newInstance("Name");
        final int[] runSize = test.getRunSize();
        final int runIter = test.getRunIterations();
        final Method[] runMethod = findMethods(clz, RUN_PREFIX);
        // do the run
        test.setUp();
        for (final int size : runSize) {
            test.startRun(size);
            for (final Method element : runMethod) {
                final Stopwatch sw = new Stopwatch();
                for (int iter = 0; iter < runIter; iter++) {
                    element.invoke(test);
                }
            // System.out.println(element.getName() + " : " + sw.getTimeString());
            }
            test.endRun();
        }
        test.tearDown();
    } catch (final Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Constructor(java.lang.reflect.Constructor) Stopwatch(com.revolsys.geometry.util.Stopwatch) Method(java.lang.reflect.Method)

Example 23 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class PointInAreaPerfTest method run.

public void run() {
    final GeometryFactory geomFactory = GeometryFactory.DEFAULT_3D;
    final SineStarFactory ssFact = new SineStarFactory();
    ssFact.setSize(1000.0);
    ssFact.setNumPoints(2000);
    ssFact.setArmLengthRatio(0.1);
    ssFact.setNumArms(100);
    final Geometry area = ssFact.newSineStar();
    // System.out.println(area);
    final Stopwatch sw = new Stopwatch();
    final PointOnGeometryLocator pia = new MCIndexedPointInAreaLocator(area);
    // PointInAreaLocator pia = new IntervalIndexedPointInAreaLocator(area);
    // PointInAreaLocator pia = new SimplePointInAreaLocator(area);
    final PointInAreaPerfTester perfTester = new PointInAreaPerfTester(geomFactory, area);
    perfTester.setNumPoints(50000);
    perfTester.setPIA(pia);
    perfTester.run();
// System.out.println("Overall time: " + sw.getTimeString());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) PointOnGeometryLocator(com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator) SineStarFactory(com.revolsys.geometry.model.util.SineStarFactory) Stopwatch(com.revolsys.geometry.util.Stopwatch)

Example 24 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class PointInAreaStressTester method run.

/**
 * @return true if all point locations were computed correctly
 */
public boolean run() {
    final Stopwatch sw = new Stopwatch();
    // default is to use the simple, non-indexed tester
    if (this.pia2 == null) {
        this.pia2 = new SimplePointInAreaLocator(this.area);
    }
    final int ptGridWidth = (int) Math.sqrt(this.numPts);
    final BoundingBox areaEnv = this.area.getBoundingBox();
    final double xStep = areaEnv.getWidth() / (ptGridWidth - 1);
    final double yStep = areaEnv.getHeight() / (ptGridWidth - 1);
    for (int i = 0; i < ptGridWidth; i++) {
        for (int j = 0; j < ptGridWidth; j++) {
            // compute test point
            final double x = this.geomFactory.makePrecise(0, areaEnv.getMinX() + i * xStep);
            final double y = this.geomFactory.makePrecise(1, areaEnv.getMinY() + j * yStep);
            final Point pt = new PointDoubleXY(x, y);
            final boolean isEqual = testPIA(pt);
            if (!isEqual) {
                return false;
            }
        }
    }
    // System.out.println("Test completed in " + sw.getTimeString());
    printStats();
    return true;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Stopwatch(com.revolsys.geometry.util.Stopwatch) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) SimplePointInAreaLocator(com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator) Point(com.revolsys.geometry.model.Point)

Example 25 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class TestPerfDistanceLinesPoints method test.

public void test(final Geometry[] pts, final Geometry target) {
    if (this.verbose) {
    // System.out.println("Query points = " + pts.length
    // + " Target points = " + target.getVertexCount());
    // if (! verbose) System.out.print(num + ", ");
    }
    final Stopwatch sw = new Stopwatch();
    final double dist = 0.0;
    for (int i = 0; i < MAX_ITER; i++) {
        computeDistance(pts, target);
    }
    if (!this.verbose) {
    // System.out.println(sw.getTimeString());
    }
    if (this.verbose) {
        final String name = USE_INDEXED_DIST ? "IndexedFacetDistance" : "Distance";
    // System.out.println(name + " - Run time: " + sw.getTimeString());
    // System.out.println(" (Distance = " + dist + ")\n");
    // System.out.println();
    }
}
Also used : Stopwatch(com.revolsys.geometry.util.Stopwatch) Point(com.revolsys.geometry.model.Point)

Aggregations

Stopwatch (com.revolsys.geometry.util.Stopwatch)30 Point (com.revolsys.geometry.model.Point)14 Geometry (com.revolsys.geometry.model.Geometry)6 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 DD (com.revolsys.geometry.math.DD)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Iterator (java.util.Iterator)2 RectangleLineIntersector (com.revolsys.geometry.algorithm.RectangleLineIntersector)1 PointOnGeometryLocator (com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator)1 SimplePointInAreaLocator (com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator)1 Interval (com.revolsys.geometry.index.bintree.Interval)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Location (com.revolsys.geometry.model.Location)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 SineStarFactory (com.revolsys.geometry.model.util.SineStarFactory)1 Constructor (java.lang.reflect.Constructor)1 Method (java.lang.reflect.Method)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1