[geos-commits] [SCM] GEOS branch master updated. 685aeb9643044376e020ca9d4d3287f3bcafef19

git at osgeo.org git at osgeo.org
Tue Jan 12 15:50:47 PST 2021


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  685aeb9643044376e020ca9d4d3287f3bcafef19 (commit)
      from  b77182f363505ccca3969a1f0a4d3e27a69e80b1 (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 685aeb9643044376e020ca9d4d3287f3bcafef19
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Tue Jan 12 15:50:41 2021 -0800

    Improve geosop timing, add --repeat

diff --git a/util/geosop/GeosOp.cpp b/util/geosop/GeosOp.cpp
index 108f076..4fe4e1c 100644
--- a/util/geosop/GeosOp.cpp
+++ b/util/geosop/GeosOp.cpp
@@ -81,6 +81,7 @@ int main(int argc, char** argv) {
         ("f,format", "Output format (wkt, wkb or txt)", cxxopts::value<std::string>( ))
         ("h,help", "Print help")
         ("p,precision", "Sets number of decimal places in output coordinates", cxxopts::value<int>( cmdArgs.precision ) )
+        ("r,repeat", "Repeat operation N times", cxxopts::value<int>( cmdArgs.repeatNum ) )
         ("t,time", "Print execution time", cxxopts::value<bool>( cmdArgs.isShowTime ) )
         ("v,verbose", "Verbose output", cxxopts::value<bool>( cmdArgs.isVerbose )->default_value("false"))
 
@@ -143,6 +144,7 @@ int main(int argc, char** argv) {
             cmdArgs.opArg1 = std::stod(val);
         }
     }
+
     GeosOp geosop(cmdArgs);
     geosop.run();
 }
@@ -310,6 +312,8 @@ GeosOp::loadInput(std::string name, std::string src, int limit) {
 }
 
 void GeosOp::run() {
+    // ensure at least one op processed
+    if (args.repeatNum < 1) args.repeatNum = 1;
 
     auto geomsLoadA = loadInput("A", args.srcA, args.limitA);
 
@@ -351,25 +355,19 @@ void GeosOp::execute() {
         exit(1);
     }
 
-    geos::util::Profile sw( op );
-    sw.start();
-
     if (fun->isBinary()) {
         executeBinary(fun);
     }
     else {
         executeUnary(fun);
     }
-
-    sw.stop();
-    totalTime = sw.getTot();
 }
 
 void GeosOp::executeUnary(GeomFunction * fun) {
     for (unsigned i = 0; i < geomA.size(); i++) {
         opCount++;
         vertexCount += geomA[i]->getNumPoints();
-        Result* result = executeOp(fun, i, geomA[i], 0, nullptr);
+        Result* result = executeOpRepeat(fun, i, geomA[i], 0, nullptr);
 
         output(result);
         delete result;
@@ -382,7 +380,7 @@ void GeosOp::executeBinary(GeomFunction * fun) {
             opCount++;
             vertexCount += geomA[ia]->getNumPoints();
             vertexCount += geomB[ib]->getNumPoints();
-            Result* result = executeOp(fun, ia, geomA[ia], ib, geomB[ib]);
+            Result* result = executeOpRepeat(fun, ia, geomA[ia], ib, geomB[ib]);
 
             output(result);
             delete result;
@@ -400,6 +398,19 @@ std::string inputDesc(std::string name, int index, const std::unique_ptr<Geometr
     return desc;
 }
 
+Result* GeosOp::executeOpRepeat(GeomFunction * fun,
+    int indexA,
+    const std::unique_ptr<Geometry>& geomA,
+    int indexB,
+    const std::unique_ptr<Geometry>& geomB)
+{
+    Result * res;
+    for (int i = 0; i < args.repeatNum; i++) {
+        res = executeOp(fun, indexA, geomA, indexB, geomB);
+    }
+    return res;
+}
+
 Result* GeosOp::executeOp(GeomFunction * fun,
     int indexA,
     const std::unique_ptr<Geometry>& geomA,
@@ -411,6 +422,8 @@ Result* GeosOp::executeOp(GeomFunction * fun,
 
     Result* result = fun->execute( geomA, geomB, args.opArg1  );
     sw.stop();
+    double time = sw.getTot();
+    totalTime += time;
 
     // avoid cost of logging if not verbose
     if (args.isVerbose) {
@@ -419,7 +432,7 @@ Result* GeosOp::executeOp(GeomFunction * fun,
             + inputDesc("A", indexA, geomA) + " "
             + inputDesc("B", indexB, geomB)
             + " -> " + result->metadata()
-            + "  --  " + timeFormatted( sw.getTot() )
+            + "  --  " + timeFormatted( time )
         );
     }
 
diff --git a/util/geosop/GeosOp.h b/util/geosop/GeosOp.h
index f38a754..df8d2f9 100644
--- a/util/geosop/GeosOp.h
+++ b/util/geosop/GeosOp.h
@@ -32,6 +32,7 @@ public:
     bool isShowTime = false;
     bool isVerbose = false;
     int precision = -1;
+    int repeatNum = 1;
 
     //std::string format;
 
@@ -73,6 +74,9 @@ private:
     void execute();
     void executeUnary(GeomFunction * fun);
     void executeBinary(GeomFunction * fun);
+    Result* executeOpRepeat(GeomFunction * fun,
+        int indexA, const  std::unique_ptr<Geometry>& geomA,
+        int indexB, const  std::unique_ptr<Geometry>& geomB);
     Result* executeOp(GeomFunction * fun,
         int indexA, const  std::unique_ptr<Geometry>& geomA,
         int indexB, const  std::unique_ptr<Geometry>& geomB);

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

Summary of changes:
 util/geosop/GeosOp.cpp | 31 ++++++++++++++++++++++---------
 util/geosop/GeosOp.h   |  4 ++++
 2 files changed, 26 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list