Package com.vividsolutions.jts.util

Examples of com.vividsolutions.jts.util.Stopwatch


        final int reqHeight = 256;

        GeneralEnvelope reqEnvelope = new GeneralEnvelope(originalEnvelope);
        reqEnvelope.setEnvelope(239038.74625, 916916.62575, 253022.8255, 930900.705);

        Stopwatch sw = new Stopwatch();
        sw.start();

        final GridCoverage2D coverage = readCoverage(reader, reqWidth, reqHeight, reqEnvelope);
        assertNotNull("read coverage returned null", coverage);

        RenderedImage image = coverage.getRenderedImage();
        writeToDisk(image, "testRead_" + tableName);
        sw.stop();
        return sw.getTime();
    }
View Full Code Here


        getReader();

        final int count = 10;
        final int threads = 30;
        final AtomicInteger writeCount = new AtomicInteger();
        Stopwatch sw = new Stopwatch();
        sw.start();

        List<Callable<Object>> tasks = new ArrayList<Callable<Object>>(threads);

        final long[] stats = { Long.MAX_VALUE, Long.MIN_VALUE, 0, 0 };// min/max/total/max mem

        for (int t = 0; t < threads; t++) {
            tasks.add(new Callable<Object>() {
                public Object call() throws Exception {
                    try {

                        final AbstractGridCoverage2DReader reader = getReader();
                        assertNotNull("Couldn't obtain a reader for " + tableName, reader);

                        final GeneralEnvelope originalEnvelope = reader.getOriginalEnvelope();
                        final GridEnvelope originalGridRange = reader.getOriginalGridRange();

                        final int reqWidth = originalGridRange.getSpan(0) / 200;
                        final int reqHeight = originalGridRange.getSpan(1) / 200;

                        for (int i = 0; i < count; i++) {
                            final GeneralEnvelope reqEnv = new GeneralEnvelope(originalEnvelope);
                            {
                                double dx = (originalEnvelope.getSpan(0) / 2) / (2 * i + 1);
                                double dy = (originalEnvelope.getSpan(1) / 2) / (2 * i + 1);
                                reqEnv.setEnvelope(originalEnvelope.getMedian(0) - dx,
                                        originalEnvelope.getMedian(1) - dy,
                                        originalEnvelope.getMedian(0) + dx,
                                        originalEnvelope.getMedian(1) + dy);
                            }

                            final GridCoverage2D coverage = readCoverage(reader, reqWidth,
                                    reqHeight, reqEnv);
                            assertNotNull("read coverage returned null", coverage);

                            RenderedImage image = coverage.view(ViewType.PHOTOGRAPHIC)
                                    .getRenderedImage();
                            // RenderedImage image =
                            // coverage.view(ViewType.NATIVE).getRenderedImage();
                            Stopwatch sw = new Stopwatch();
                            sw.start();
                            writeToDisk(image, "testRead_" + tableName);
                            sw.stop();
                            long memMB = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
                                    .freeMemory()) / 1024 / 1024;
                            System.err.println("wrote #" + writeCount.incrementAndGet() + " in "
                                    + sw.getTimeString() + ": Mem: " + memMB + "M. Thread: "
                                    + Thread.currentThread().getName() + ", iteration #" + i);

                            synchronized (stats) {
                                stats[0] = Math.min(stats[0], sw.getTime());
                                stats[1] = Math.max(stats[1], sw.getTime());
                                stats[2] = stats[2] + sw.getTime();
                                stats[3] = Math.max(stats[3], memMB);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        throw e;
                    }
                    return null;
                }
            });
        }

        ExecutorService threadPool = Executors.newFixedThreadPool(threads);
        threadPool.invokeAll(tasks);

        threadPool.shutdown();
        while (!threadPool.isTerminated()) {
            Thread.sleep(100);
        }
        sw.stop();
        System.err.println("____ Finished in " + sw.getTimeString() + ". Min: " + stats[0]
                + ", Max: " + stats[1] + ", total execution time: " + stats[2] + ", Avg: "
                + (stats[2] / (threads * count)) + ". Max mem: " + stats[3] + "MB");
        System.err.println("__________________\n  SNAPSHOT!!!!!!!!");
        // Thread.sleep(5000);
    }
View Full Code Here

    return fileRdr.read();
  }

  void testAllDistances(List geoms, int maxToScan)
  {
    Stopwatch sw = new Stopwatch();
   
    computeAllDistances(geoms, maxToScan);
//  computePairDistance(geoms, 1, 3);
//  computePairDistance(geoms, 55, 77);
   
    System.out.println("Count = " + maxToScan
        + "   Finished in " + sw.getTimeString());   
  }
View Full Code Here

    System.out.println("# pts: " + pts.length);
       
    RectangleLineIntersector rectSegIntersector = new RectangleLineIntersector(rectEnv);
    SimpleRectangleIntersector rectSideIntersector = new SimpleRectangleIntersector(rectEnv);

    Stopwatch sw = new Stopwatch();

    for (int i = 0; i < pts.length; i++) {
      for (int j = 0; j < pts.length; j++) {
        if (i == j) continue;
       
        boolean segResult = false;
        if (useSegInt)
          segResult = rectSegIntersector.intersects(pts[i], pts[j]);
        boolean sideResult = false;
        if (useSideInt)
          sideResult = rectSideIntersector.intersects(pts[i], pts[j]);
       
        if (useSegInt && useSideInt)
        {
          if (segResult != sideResult)
            throw new IllegalStateException("Seg and Side values do not match");
        }
      }
    }
   
    System.out.println("Finished in " + sw.getTimeString());
    System.out.println();
  }
View Full Code Here

  public void run(String testName, int testType)
  {
    System.out.println();
    System.out.println("======= Union Algorithm: " + testName + " ===========");

    Stopwatch sw = new Stopwatch();
    for (int i = 0; i < MAX_ITER; i++) {
      Geometry union = null;
      switch (testType) {
      case CASCADED:
        union = unionCascaded(polys);
        break;
      case ITERATED:
        union = unionAllSimple(polys);
        break;
      case BUFFER0:
        union = unionAllBuffer(polys);
        break;
      }
     
//      printFormatted(union);

    }
    System.out.println("Finished in " + sw.getTimeString());
  }
View Full Code Here

    System.out.println("Target # pts: " + g.getNumPoints()
        + "  -- # Rectangles: " + rect.length
        );

    int maxCount = MAX_ITER;
    Stopwatch sw = new Stopwatch();
    int count = 0;
    for (int i = 0; i < MAX_ITER; i++) {
      for (int j = 0; j < rect.length; j++) {
//      rect[j].relate(g);
        rect[j].intersects(g);
      }
    }
    System.out.println("Finished in " + sw.getTimeString());
    System.out.println();
  }
View Full Code Here

  {
    if (verbose) System.out.println("Query points = " + pts.length
        + "     Target points = " + target.getNumPoints());
//    if (! verbose) System.out.print(num + ", ");
   
    Stopwatch sw = new Stopwatch();
    double dist = 0.0;
    for (int i = 0; i < MAX_ITER; i++) {
      computeDistance(pts, target);
    }
    if (! verbose) System.out.println(sw.getTimeString());
    if (verbose) {
      String name = USE_INDEXED_DIST ? "IndexedFacetDistance" : "Distance";
      System.out.println(name + " - Run time: " + sw.getTimeString());
      //System.out.println("       (Distance = " + dist + ")\n");
      System.out.println();
    }
  }
View Full Code Here

    test(geom);
  }
 
  public void test(Geometry[] geom)
  {
    Stopwatch sw = new Stopwatch();
    double dist = 0.0;
    for (int i = 0; i < MAX_ITER; i++) {
      testAll(geom);
    }
    if (! verbose) System.out.println(sw.getTimeString());
    if (verbose) {
      System.out.println("Finished in " + sw.getTimeString());
      System.out.println("       (Distance = " + dist + ")");
    }
  }
View Full Code Here

    test(geom);
  }
 
  public void test(Geometry[] geom)
  {
    Stopwatch sw = new Stopwatch();
    double dist = 0.0;
    double dist2 = 0.0;
    for (int i = 0; i < MAX_ITER; i++) {
     
//      dist = geom[0].distance(geom[1]);
//    dist = SortedBoundsFacetDistance.distance(g1, g2);
//      dist2 = BranchAndBoundFacetDistance.distance(geom[0], geom[1]);
//    if (dist != dist2) System.out.println("distance discrepancy found!");
     
     
      computeDistanceToAllPoints(geom);
    }
    if (! verbose) System.out.println(sw.getTimeString());
    if (verbose) {
      System.out.println("Finished in " + sw.getTimeString());
      System.out.println("       (Distance = " + dist + ")");
    }
  }
View Full Code Here

    //queryGrid(200);
  }

  void queryGrid(int nGridCells, double cellSize)
  {
    Stopwatch sw = new Stopwatch();
    sw.start();

    int gridSize = (int) Math.sqrt((double) nGridCells);
    gridSize += 1;
    double extent = MAX_EXTENT - MIN_EXTENT;
    double gridInc = extent / gridSize;

    for (int i = 0; i < gridSize; i++) {
        double x = MIN_EXTENT + gridInc * i;
        Interval interval = new Interval(x, x + cellSize);
        queryTest(interval);
        //queryTime(env);
    }
    System.out.println("Time = " + sw.getTimeString());
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.util.Stopwatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.