[geos-commits] [SCM] GEOS branch master updated. 314960229dc44d5379aed57aed94c5190384c883
git at osgeo.org
git at osgeo.org
Fri Feb 15 15:23:53 PST 2019
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, master has been updated
via 314960229dc44d5379aed57aed94c5190384c883 (commit)
from d4b4def27b34dd8811af7cbee7b74f2f902217f7 (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 314960229dc44d5379aed57aed94c5190384c883
Author: mdavis <mtnclimb at gmail.com>
Date: Fri Feb 15 15:23:53 2019 -0800
Add InteriorPoint Area perf test, Profile enhancement (#63)
diff --git a/include/geos/profiler.h b/include/geos/profiler.h
index 853d598..c447704 100644
--- a/include/geos/profiler.h
+++ b/include/geos/profiler.h
@@ -112,6 +112,9 @@ public:
/** \brief Return total timing */
double getTot() const;
+ /** \brief Return total timing */
+ std::string getTotFormatted() const;
+
/** \brief Return average timing */
double getAvg() const;
diff --git a/src/util/Profiler.cpp b/src/util/Profiler.cpp
index f3b7ca2..a8cb156 100644
--- a/src/util/Profiler.cpp
+++ b/src/util/Profiler.cpp
@@ -58,6 +58,19 @@ Profile::getTot() const
return totaltime;
}
+std::string
+Profile::getTotFormatted() const
+{
+ long usec = (long) totaltime;
+ std::string fmt = to_string(usec);
+ int insertPosition = fmt.length() - 3;
+ while (insertPosition > 0) {
+ fmt.insert(insertPosition, ",");
+ insertPosition-=3;
+ }
+ return fmt + " usec";
+}
+
size_t
Profile::getNumTimings() const
{
diff --git a/tests/perf/CMakeLists.txt b/tests/perf/CMakeLists.txt
index 4354dee..78c55ad 100644
--- a/tests/perf/CMakeLists.txt
+++ b/tests/perf/CMakeLists.txt
@@ -24,6 +24,7 @@ if(GEOS_ENABLE_TESTS)
# add_test(perf_class_sizes ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perf_class_sizes)
+ add_subdirectory(algorithm)
add_subdirectory(operation)
add_subdirectory(capi)
diff --git a/tests/perf/algorithm/CMakeLists.txt b/tests/perf/algorithm/CMakeLists.txt
new file mode 100644
index 0000000..7272dd0
--- /dev/null
+++ b/tests/perf/algorithm/CMakeLists.txt
@@ -0,0 +1,17 @@
+#################################################################################
+#
+# CMake configuration for GEOS perf/operation/predicate tests
+#
+# Copyright (C) 2017 Mateusz Loskot <mateusz at loskot.net>
+#
+# This is free software; you can redistribute and/or modify it under
+# the terms of the GNU Lesser General Public Licence as published
+# by the Free Software Foundation.
+# See the COPYING file for more information.
+#
+#################################################################################
+
+add_executable(perf_interiorpoint_area InteriorPointAreaPerfTest.cpp)
+
+target_link_libraries(perf_interiorpoint_area geos)
+
diff --git a/tests/perf/algorithm/InteriorPointAreaPerfTest.cpp b/tests/perf/algorithm/InteriorPointAreaPerfTest.cpp
new file mode 100644
index 0000000..1381265
--- /dev/null
+++ b/tests/perf/algorithm/InteriorPointAreaPerfTest.cpp
@@ -0,0 +1,139 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2011 Sandro Santilli <strk at kbt.io>
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ **********************************************************************
+ *
+ * Last port: perf/operation/predicate/RectangleIntersectsPerfTest.java r378 (JTS-1.12)
+ *
+ **********************************************************************/
+
+
+#include <geos/geom/PrecisionModel.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/util/GeometricShapeFactory.h>
+#include <geos/precision/SimpleGeometryPrecisionReducer.h>
+#include <geos/geom/util/SineStarFactory.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/Polygon.h>
+#include <geos/geom/Point.h>
+#include <geos/profiler.h>
+#include <iostream>
+#include <vector>
+#include <cmath>
+#include <sstream>
+#include <memory>
+
+using namespace geos::geom;
+using namespace geos::io;
+using namespace std;
+
+class InteriorPointAreaPerfTest {
+public:
+ InteriorPointAreaPerfTest()
+ :
+ pm(),
+ fact(GeometryFactory::create(&pm, 0))
+ {
+ showHeader();
+ }
+
+ void
+ test(int nPts)
+ {
+ Coordinate origin(ORG_X, ORG_Y);
+ std::unique_ptr<Polygon> sinePoly =
+ createSineStar(origin, SIZE, nPts);
+
+ /**
+ * Make the geometry "crinkly" by rounding off the points.
+ * This defeats the MonotoneChain optimization in the full relate
+ * algorithm, and provides a more realistic test.
+ */
+ using geos::precision::SimpleGeometryPrecisionReducer;
+ PrecisionModel p_pm(SIZE);
+ SimpleGeometryPrecisionReducer reducer(&p_pm);
+ std::unique_ptr<Geometry> sinePolyCrinkly(reducer.reduce(sinePoly.get()));
+ sinePoly.reset();
+
+ //cout << sinePolyCrinkly->toText() << endl;
+
+ test(*sinePolyCrinkly);
+ }
+
+ const double ORG_X = 100.0;
+ const double ORG_Y = 100.0;
+ const double SIZE = 100.0;
+ const int N_ARMS = 20;
+ const double ARM_RATIO = 0.3;
+ const int N_ITER = 100;
+
+private:
+ PrecisionModel pm;
+ GeometryFactory::Ptr fact;
+
+ void
+ showHeader() {
+ cout << "Interior Point Area perf test" << endl;
+ cout << "# Iterations: " << N_ITER << endl;
+ cout << "SineStar: origin: ("
+ << ORG_X << ", " << ORG_Y
+ << ") size: " << SIZE
+ << " # arms: " << N_ARMS
+ << " arm ratio: " << ARM_RATIO
+ << endl;
+ }
+
+ void
+ test(geos::geom::Geometry& poly)
+ {
+ typedef vector<const Geometry*>::size_type size_type;
+
+ geos::util::Profile sw("");
+ sw.start();
+
+ for(int i = 0; i < N_ITER; i++) {
+ std::unique_ptr<geos::geom::Point> pt( poly.getInteriorPoint() );
+ }
+
+ sw.stop();
+ cout << poly.getNumPoints() << " points: " << sw.getTotFormatted() << endl;
+
+ }
+
+ std::unique_ptr<Polygon>
+ createSineStar(const Coordinate& origin,
+ double size, int nPts)
+ {
+ using geos::geom::util::SineStarFactory;
+
+ SineStarFactory gsf(fact.get());
+ gsf.setCentre(origin);
+ gsf.setSize(size);
+ gsf.setNumPoints(nPts);
+ gsf.setArmLengthRatio( ARM_RATIO );
+ gsf.setNumArms( N_ARMS );
+ std::unique_ptr<Polygon> poly = gsf.createSineStar();
+ return poly;
+ }
+};
+
+int
+main()
+{
+ InteriorPointAreaPerfTest tester;
+
+ tester.test(1000);
+ tester.test(10000);
+ tester.test(100000);
+ tester.test(1000000);
+}
+
diff --git a/tests/perf/algorithm/Makefile.am b/tests/perf/algorithm/Makefile.am
new file mode 100644
index 0000000..d7560d6
--- /dev/null
+++ b/tests/perf/algorithm/Makefile.am
@@ -0,0 +1,18 @@
+#
+# This file is part of project GEOS (http://trac.osgeo.org/geos/)
+#
+prefix=@prefix@
+top_srcdir=@top_srcdir@
+top_builddir=@top_builddir@
+
+noinst_PROGRAMS = InteriorPointAreaPerfTest
+
+LIBS = $(top_builddir)/src/libgeos.la
+
+InteriorPointAreaPerfTest_SOURCES = InteriorPointAreaPerfTest.cpp
+InteriorPointAreaPerfTest_LDADD = $(LIBS)
+
+AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/src/io/markup
+
+EXTRA_DIST = CMakeLists.txt
-----------------------------------------------------------------------
Summary of changes:
include/geos/profiler.h | 3 +
src/util/Profiler.cpp | 13 +++
tests/perf/CMakeLists.txt | 1 +
tests/perf/{operation => algorithm}/CMakeLists.txt | 8 +-
.../InteriorPointAreaPerfTest.cpp} | 107 ++++++++-------------
.../{operation/buffer => algorithm}/Makefile.am | 7 +-
6 files changed, 67 insertions(+), 72 deletions(-)
copy tests/perf/{operation => algorithm}/CMakeLists.txt (70%)
copy tests/perf/{operation/predicate/RectangleIntersectsPerfTest.cpp => algorithm/InteriorPointAreaPerfTest.cpp} (50%)
copy tests/perf/{operation/buffer => algorithm}/Makefile.am (55%)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list