Skip to content

Commit

Permalink
Add numTests arg to topo pred benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Nov 22, 2024
1 parent 8d98eab commit 1ab10dd
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions benchmarks/geom/TopologyPredicatePerfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Tests a target geometry against grids of points, lines and polygons covering the target.
* Target is either a geometry from a WKT file or a set of generated sine stars increasing in size.
*
* Usage: perf_topo_predicate [WKT file] [ intersects | contains | covers | touches ]
* Usage: perf_topo_predicate [WKT file] [ intersects | contains | covers | touches ] [num target geoms]
******************************************************/

#include <geos/geom/util/SineStarFactory.h>
Expand All @@ -28,8 +28,8 @@ using namespace geos::geom;
using geos::operation::relate::RelateOp;

std::size_t MAX_ITER = 1;
std::size_t NUM_LINES = 10000;
std::size_t NUM_LINES_PTS = 100;
std::size_t NUM_GEOM = 1000;
std::size_t NUM_PTS = 100;

#define INTERSECTS 0
#define CONTAINS 1
Expand All @@ -39,6 +39,7 @@ std::size_t NUM_LINES_PTS = 100;
std::string inputFilename{""};
std::string predicateName{"intersects"};
int predicateOp = INTERSECTS;
std::size_t numTestGeometries = NUM_GEOM;

int testRelateOpIntersects(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
int count = 0;
Expand Down Expand Up @@ -218,13 +219,16 @@ void testTarget(int dim, Geometry& target) {
std::vector<std::unique_ptr<Geometry>> geoms;
switch (dim) {
case 0:
geoms = geos::benchmark::createPoints(*target.getEnvelopeInternal(), NUM_LINES);
geoms = geos::benchmark::createPoints(*target.getEnvelopeInternal(),
numTestGeometries);
break;
case 1:
geoms = geos::benchmark::createLines(*target.getEnvelopeInternal(), NUM_LINES, 1.0, NUM_LINES_PTS);
geoms = geos::benchmark::createLines(*target.getEnvelopeInternal(),
numTestGeometries, 1.0, NUM_PTS);
break;
case 2:
geoms = geos::benchmark::createPolygons(*target.getEnvelopeInternal(), NUM_LINES, 1.0, NUM_LINES_PTS);
geoms = geos::benchmark::createPolygons(*target.getEnvelopeInternal(),
numTestGeometries, 1.0, NUM_PTS);
break;
}
double baseTime;
Expand Down Expand Up @@ -275,14 +279,22 @@ void testStarAll(int dim)
void parseArgs(int argc, char** argv) {
int iPred = -1;
int iFile = -1;
if (argc == 2) {
iPred = 1;
}
else if (argc >= 3) {
iFile = 1;
iPred = 2;
//-- parse filename, predicate, num geoms, if present
for (int i = 1; i < argc; i++) {
std::string arg = argv[i];
if (arg.find(".") != std::string::npos)
iFile = i;
else {
bool isInt = (arg.find_first_not_of( "0123456789" ) == std::string::npos);
if (isInt) {
numTestGeometries = (size_t) std::stoi(arg);
}
else {
iPred = i;
}
}
}
//predicateName = "intersects";

if (iPred > 0) {
predicateName = argv[iPred];
}
Expand Down

0 comments on commit 1ab10dd

Please # to comment.