[geos-commits] r2395 - in trunk: . tests tests/perf tests/perf/operation tests/perf/operation/buffer

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Apr 20 06:37:28 EDT 2009


Author: strk
Date: 2009-04-20 06:37:28 -0400 (Mon, 20 Apr 2009)
New Revision: 2395

Added:
   trunk/tests/perf/
   trunk/tests/perf/Makefile.am
   trunk/tests/perf/operation/
   trunk/tests/perf/operation/Makefile.am
   trunk/tests/perf/operation/buffer/
   trunk/tests/perf/operation/buffer/IteratedBufferStressTest.cpp
   trunk/tests/perf/operation/buffer/Makefile.am
Modified:
   trunk/configure.in
   trunk/tests/Makefile.am
Log:
Port IteratedBufferStessTest


Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2009-04-20 09:37:55 UTC (rev 2394)
+++ trunk/configure.in	2009-04-20 10:37:28 UTC (rev 2395)
@@ -357,6 +357,9 @@
 	tests/Makefile
 	tests/bigtest/Makefile
 	tests/unit/Makefile
+	tests/perf/Makefile
+	tests/perf/operation/Makefile
+	tests/perf/operation/buffer/Makefile
 	tests/xmltester/Makefile
 	tools/Makefile
 	tools/geos-config

Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am	2009-04-20 09:37:55 UTC (rev 2394)
+++ trunk/tests/Makefile.am	2009-04-20 10:37:28 UTC (rev 2395)
@@ -1,5 +1,6 @@
 SUBDIRS = \
 	bigtest		\
 	xmltester	\
-	unit
+	unit		\
+	perf
 

Added: trunk/tests/perf/Makefile.am
===================================================================
--- trunk/tests/perf/Makefile.am	                        (rev 0)
+++ trunk/tests/perf/Makefile.am	2009-04-20 10:37:28 UTC (rev 2395)
@@ -0,0 +1,3 @@
+SUBDIRS = \
+	operation		
+

Added: trunk/tests/perf/operation/Makefile.am
===================================================================
--- trunk/tests/perf/operation/Makefile.am	                        (rev 0)
+++ trunk/tests/perf/operation/Makefile.am	2009-04-20 10:37:28 UTC (rev 2395)
@@ -0,0 +1,3 @@
+SUBDIRS = \
+	buffer		
+

Added: trunk/tests/perf/operation/buffer/IteratedBufferStressTest.cpp
===================================================================
--- trunk/tests/perf/operation/buffer/IteratedBufferStressTest.cpp	                        (rev 0)
+++ trunk/tests/perf/operation/buffer/IteratedBufferStressTest.cpp	2009-04-20 10:37:28 UTC (rev 2395)
@@ -0,0 +1,86 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2009  Sandro Santilli <strk at keybit.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.
+ *
+ **********************************************************************
+ *
+ * Last port: perf/operation/buffer/IteratedBufferStressTest.java rev 1.1
+ *
+ * - Added exit condition when number of vertices is zero
+ *
+ **********************************************************************/
+
+
+#include <geos/geom/PrecisionModel.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/io/WKTReader.h>
+#include <geos/geom/Geometry.h>
+#include <geos/profiler.h>
+#include <iostream>
+
+using namespace geos::geom;
+using namespace geos::io;
+using namespace std;
+
+typedef auto_ptr<Geometry> GeomPtr;
+
+GeomPtr doBuffer(const Geometry& g, double dist)
+{
+ cout << "Buffering with dist = " << dist << endl;
+ GeomPtr buf ( g.buffer(dist) );
+ cout << "Buffer result has " <<  buf->getNumPoints() << " vertices" << endl;
+
+ //cout << *buf << endl;
+
+ return buf;
+}
+
+// throws Exception
+void run(const Geometry* base)
+{
+	GeomPtr tmp;
+
+	// profile here
+	geos::util::Profile totalSW("buffer");
+	double dist = 1.0;
+	while (true) {
+
+		totalSW.start();
+
+		GeomPtr b1 = doBuffer(*base, dist);
+		GeomPtr b2 = doBuffer(*b1, -dist);
+
+		totalSW.stop();
+		cout << "----------------------  "
+		     << totalSW << endl; // totalSW.getTimeString() << endl;
+
+		dist += 1;
+		base = b2.get(); tmp = b2;
+
+		if ( ! base->getNumPoints() ) break;
+	}
+}
+
+int
+main()
+{
+	PrecisionModel pm;
+	GeometryFactory gf(&pm);
+	WKTReader rdr(&gf);
+
+	string inputWKT =
+        "POLYGON ((110 320, 190 220, 60 200, 180 120, 120 40, 290 150, 410 40, 410 230, 500 340, 320 310, 260 370, 220 310, 110 320), (220 260, 250 180, 290 220, 360 150, 350 250, 260 280, 220 260))";
+
+        GeomPtr base ( rdr.read(inputWKT) );
+	run(base.get());
+}
+

Added: trunk/tests/perf/operation/buffer/Makefile.am
===================================================================
--- trunk/tests/perf/operation/buffer/Makefile.am	                        (rev 0)
+++ trunk/tests/perf/operation/buffer/Makefile.am	2009-04-20 10:37:28 UTC (rev 2395)
@@ -0,0 +1,13 @@
+prefix=@prefix@
+top_srcdir=@top_srcdir@
+top_builddir=@top_builddir@
+
+noinst_PROGRAMS = IteratedBufferStressTest
+
+LIBS = $(top_builddir)/source/libgeos.la
+
+IteratedBufferStressTest_SOURCES = IteratedBufferStressTest.cpp 
+IteratedBufferStressTest_LDADD = $(LIBS)
+
+INCLUDES = -I$(top_srcdir)/source/headers
+INCLUDES += -I$(top_srcdir)/source/io/markup



More information about the geos-commits mailing list