[geos-commits] [SCM] GEOS branch main-relate-ng updated. 0983ab4027ce6e696d56bea89e8cdcea73315f99

git at osgeo.org git at osgeo.org
Tue Aug 6 11:48:05 PDT 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main-relate-ng has been updated
       via  0983ab4027ce6e696d56bea89e8cdcea73315f99 (commit)
      from  2c9b3cd652118d17af99e1ee902d498f780f7af9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0983ab4027ce6e696d56bea89e8cdcea73315f99
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Tue Aug 6 11:47:41 2024 -0700

    Improve PreparedPolygonIntersects test

diff --git a/benchmarks/BenchmarkUtils.h b/benchmarks/BenchmarkUtils.h
index c3780d51a..5793e4c4e 100644
--- a/benchmarks/BenchmarkUtils.h
+++ b/benchmarks/BenchmarkUtils.h
@@ -58,6 +58,12 @@ createLine(const geom::CoordinateXY& base, double size, std::size_t npts) {
 }
 
 
+std::vector<std::unique_ptr<geom::Geometry>>
+createPolygons(const geom::Envelope& env, std::size_t nItems, double size, std::size_t npts) {
+    return createGeometriesOnGrid(env, nItems, [size, npts](const geom::CoordinateXY& base) {
+        return createSineStar(base, size, npts);
+    });
+}
 std::vector<std::unique_ptr<geom::Geometry>>
 createLines(const geom::Envelope& env, std::size_t nItems, double size, std::size_t npts) {
     return createGeometriesOnGrid(env, nItems, [size, npts](const geom::CoordinateXY& base) {
diff --git a/benchmarks/geom/PreparedPolygonIntersectsPerfTest.cpp b/benchmarks/geom/PreparedPolygonIntersectsPerfTest.cpp
index 0432cecaf..04fa95c84 100644
--- a/benchmarks/geom/PreparedPolygonIntersectsPerfTest.cpp
+++ b/benchmarks/geom/PreparedPolygonIntersectsPerfTest.cpp
@@ -3,9 +3,13 @@
 #include <geos/profiler.h>
 #include <geos/geom/IntersectionMatrix.h>
 #include <geos/geom/prep/PreparedGeometryFactory.h>
+#include <geos/operation/relateng/RelateNG.h>
+#include <geos/operation/relateng/RelatePredicate.h>
 #include <geos/io/WKBWriter.h>
 #include <BenchmarkUtils.h>
 
+#include <iomanip>
+
 using namespace geos::geom;
 
 std::size_t MAX_ITER = 10;
@@ -47,33 +51,63 @@ int testPrepGeomCached(const Geometry& g, const std::vector<std::unique_ptr<Geom
     return count;
 }
 
+int testRelateNGPreparedCached(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& lines) {
+    int count = 0;
+    auto prep = geos::operation::relateng::RelateNG::prepare(&g);
+    for (const auto& line : lines) {
+        count += prep->evaluate(line.get(), *geos::operation::relateng::RelatePredicate::intersects());
+    }
+    return count;
+}
+
 template<typename F>
-void test(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& lines, const std::string& method, F&& fun)
+double test(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms, const std::string& method, F&& fun, double base)
 {
     geos::util::Profile sw("PreparedPolygonIntersects");
     sw.start();
 
     int count = 0;
     for (std::size_t i = 0; i < MAX_ITER; i++) {
-        count += fun(g, lines);
+        count += fun(g, geoms);
     }
 
     sw.stop();
-    std::cout << g.getNumPoints() << "," << MAX_ITER * lines.size() << "," << count << "," << lines[0]->getGeometryType() << "," << lines[0]->getNumPoints() << "," << method << "," << sw.getTot() << std::endl;
+    double tot = sw.getTot();
+    double timesFaster = base / tot;
+    std::cout << std::fixed << std::setprecision(0);
+    std::cout << g.getNumPoints() << "," 
+        << MAX_ITER * geoms.size() << "," 
+        << count << "," << geoms[0]->getGeometryType() << "," 
+        << geoms[0]->getNumPoints() << "," 
+        << method << "," 
+        << tot << ","
+        << timesFaster 
+        << std::endl;
+    return tot;
 }
 
 void test (std::size_t npts) {
 
     auto target = geos::benchmark::createSineStar({0, 0}, 100, npts);
+    auto polygons = geos::benchmark::createPolygons(*target->getEnvelopeInternal(), NUM_LINES, 1.0, NUM_LINES_PTS);
     auto lines = geos::benchmark::createLines(*target->getEnvelopeInternal(), NUM_LINES, 1.0, NUM_LINES_PTS);
     auto points = geos::benchmark::createPoints(*target->getEnvelopeInternal(), NUM_LINES);
 
-    test(*target, lines, "RelateOp", testRelateOp);
-    test(*target, lines, "Geometry::intersects", testGeometryIntersects);
-    test(*target, lines, "PrepGeomCached", testPrepGeomCached);
-    test(*target, points, "RelateOp", testRelateOp);
-    test(*target, points, "Geometry::intersects", testGeometryIntersects);
-    test(*target, points, "PrepGeomCached", testPrepGeomCached);
+    double base;
+    base = test(*target, polygons, "RelateOp", testRelateOp, 0);
+    test(*target, polygons, "Geometry::intersects", testGeometryIntersects, base);
+    test(*target, polygons, "PrepGeomCached", testPrepGeomCached, base);
+    test(*target, polygons, "RelateNGPreparedCached", testRelateNGPreparedCached, base);
+
+    base = test(*target, lines, "RelateOp", testRelateOp, 0);
+    test(*target, lines, "Geometry::intersects", testGeometryIntersects, base);
+    test(*target, lines, "PrepGeomCached", testPrepGeomCached, base);
+    test(*target, lines, "RelateNGPreparedCached", testRelateNGPreparedCached, base);
+
+    base = test(*target, points, "RelateOp", testRelateOp, 0);
+    test(*target, points, "Geometry::intersects", testGeometryIntersects, base);
+    test(*target, points, "PrepGeomCached", testPrepGeomCached, base);
+    test(*target, points, "RelateNGPreparedCached", testRelateNGPreparedCached, base);
 }
 
 int main() {

-----------------------------------------------------------------------

Summary of changes:
 benchmarks/BenchmarkUtils.h                        |  6 +++
 .../geom/PreparedPolygonIntersectsPerfTest.cpp     | 52 ++++++++++++++++++----
 2 files changed, 49 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list