[geos-commits] r3349 - in trunk: . tests/perf tests/perf/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Wed May 11 13:25:51 EDT 2011


Author: strk
Date: 2011-05-11 10:25:51 -0700 (Wed, 11 May 2011)
New Revision: 3349

Added:
   trunk/tests/perf/capi/
   trunk/tests/perf/capi/Makefile.am
   trunk/tests/perf/capi/memleak_mp_prep.c
   trunk/tests/perf/capi/memleak_mp_prep.sh
Modified:
   trunk/configure.in
   trunk/tests/perf/Makefile.am
Log:
Import test for bug #342. It is not automated as it's not general (requires bash)

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2011-05-11 10:00:51 UTC (rev 3348)
+++ trunk/configure.in	2011-05-11 17:25:51 UTC (rev 3349)
@@ -509,6 +509,7 @@
 	tests/perf/operation/Makefile
 	tests/perf/operation/buffer/Makefile
 	tests/perf/operation/predicate/Makefile
+	tests/perf/capi/Makefile
 	tests/xmltester/Makefile
 	tests/geostest/Makefile
 	tests/thread/Makefile

Modified: trunk/tests/perf/Makefile.am
===================================================================
--- trunk/tests/perf/Makefile.am	2011-05-11 10:00:51 UTC (rev 3348)
+++ trunk/tests/perf/Makefile.am	2011-05-11 17:25:51 UTC (rev 3349)
@@ -3,5 +3,6 @@
 # This file is part of project GEOS (http://trac.osgeo.org/geos/) 
 #
 SUBDIRS = \
-	operation
+	operation \
+	capi
 

Added: trunk/tests/perf/capi/Makefile.am
===================================================================
--- trunk/tests/perf/capi/Makefile.am	                        (rev 0)
+++ trunk/tests/perf/capi/Makefile.am	2011-05-11 17:25:51 UTC (rev 3349)
@@ -0,0 +1,18 @@
+# $Id: Makefile.am 2841 2010-01-13 00:48:20Z mloskot $
+#
+#
+# This file is part of project GEOS (http://trac.osgeo.org/geos/) 
+#
+prefix=@prefix@
+top_srcdir=@top_srcdir@
+top_builddir=@top_builddir@
+
+check_PROGRAMS = memleak_mp_prep
+
+LIBS = $(top_builddir)/capi/libgeos_c.la
+
+memleak_mp_prep_SOURCES = memleak_mp_prep.c
+memleak_mp_prep_LDADD = $(LIBS)
+
+#INCLUDES = -I$(top_srcdir)/include
+#INCLUDES += -I$(top_srcdir)/src/io/markup

Added: trunk/tests/perf/capi/memleak_mp_prep.c
===================================================================
--- trunk/tests/perf/capi/memleak_mp_prep.c	                        (rev 0)
+++ trunk/tests/perf/capi/memleak_mp_prep.c	2011-05-11 17:25:51 UTC (rev 3349)
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <assert.h>
+#include "geos_c.h"
+
+int main(void) {
+  GEOSWKTReader *reader;
+  GEOSGeometry *mp;
+  GEOSGeometry *p;
+  const GEOSPreparedGeometry *prep_mp;
+  unsigned long int i;
+  unsigned long int count = 1e6;
+  
+  initGEOS(NULL, NULL);
+  
+  reader = GEOSWKTReader_create();
+  
+  mp = GEOSWKTReader_read(reader, 
+    "MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))");
+  
+  p = GEOSWKTReader_read(reader, 
+    "POLYGON((2 2, 6 2, 6 6, 2 6, 2 2))");
+
+  assert(GEOSisValid(mp));
+  assert(GEOSisValid(p));
+  
+  prep_mp = GEOSPrepare(mp);
+  
+  for (i=0; i<count; i++) {
+
+    if ( !(i%100) ) printf("%lu iterations\n", i);
+
+    /* does not leak */
+    /* GEOSContains(mp, p); */
+    
+    /* leaks */
+    GEOSPreparedContains(prep_mp, p);
+  }
+
+  printf("%lu iterations (END)\n", i);
+}

Added: trunk/tests/perf/capi/memleak_mp_prep.sh
===================================================================
--- trunk/tests/perf/capi/memleak_mp_prep.sh	                        (rev 0)
+++ trunk/tests/perf/capi/memleak_mp_prep.sh	2011-05-11 17:25:51 UTC (rev 3349)
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# tweak the number till you get a few lines of output and a segfault..
+ulimit -v $((1024*18))
+
+./memleak_mp_prep



More information about the geos-commits mailing list