[postgis-commits] svn - r3307 - in trunk: . lwgeom

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Thu Nov 20 07:00:59 PST 2008


Author: mcayland
Date: 2008-11-20 07:00:57 -0800 (Thu, 20 Nov 2008)
New Revision: 3307

Modified:
   trunk/configure.ac
   trunk/lwgeom/lwgeom_geos.c
   trunk/lwgeom/profile.h
   trunk/postgis_config.h.in
Log:
Switch GEOS profiling over to use conditional macros, much in the same way as LWDEBUG(F) has been implemented. This improves code readability by not having constant #if...#endif sections throughout the code. I've also changed the variable that indicates whether profiling has been enabled to POSTGIS_PROFILE, and integrated it into the autoconf configuration. Hence profiling can be enabled by running configure with the --enable-profile option, or setting POSTGIS_PROFILE in postgis_config.h to 1 and re-compiling.


Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2008-11-20 13:42:00 UTC (rev 3306)
+++ trunk/configure.ac	2008-11-20 15:00:57 UTC (rev 3307)
@@ -426,7 +426,15 @@
 
 AC_DEFINE_UNQUOTED([POSTGIS_DEBUG_LEVEL], [$POSTGIS_DEBUG_LEVEL], [PostGIS library debug level (0=disabled)])
 
+dnl
+dnl Allow the user to enable GEOS profiling with --enable-profile
+dnl
 
+AC_ARG_ENABLE([profile], AC_HELP_STRING([--enable-profile], [Enable GEOS profiling messages]), 
+	[POSTGIS_PROFILE=1], [POSTGIS_PROFILE=0]) 
+
+AC_DEFINE_UNQUOTED([POSTGIS_PROFILE], [$POSTGIS_PROFILE], [Enable GEOS profiling (0=disabled)])
+
 dnl
 dnl Define version macros
 dnl

Modified: trunk/lwgeom/lwgeom_geos.c
===================================================================
--- trunk/lwgeom/lwgeom_geos.c	2008-11-20 13:42:00 UTC (rev 3306)
+++ trunk/lwgeom/lwgeom_geos.c	2008-11-20 15:00:57 UTC (rev 3307)
@@ -345,9 +345,7 @@
 
 	POSTGIS_DEBUG(2, "in geomunion");
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -360,31 +358,20 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
 	POSTGIS_DEBUGF(3, "g1=%s", GEOSGeomToWKT(g1));
 	POSTGIS_DEBUGF(3, "g2=%s", GEOSGeomToWKT(g2));
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSUnion(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	POSTGIS_DEBUGF(3, "g3=%s", GEOSGeomToWKT(g3));
 
@@ -400,13 +387,9 @@
 
 	GEOSSetSRID(g3, SRID);
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, is3d);
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
 
 	GEOSGeom_destroy(g3);
 
@@ -418,10 +401,8 @@
 
 	/* compressType(result); */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -445,9 +426,7 @@
 	int is3d;
 	int SRID;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -460,28 +439,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSSymDifference(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -495,13 +463,9 @@
 
 	GEOSSetSRID(g3, SRID);
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, is3d);
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
 
 	if (result == NULL)
 	{
@@ -518,10 +482,8 @@
 
 	/* compressType(result); */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -538,9 +500,7 @@
 	PG_LWGEOM *result;
 	int SRID;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
@@ -548,21 +508,13 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1 );
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSBoundary(g1);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -575,14 +527,11 @@
 
 	GEOSSetSRID(g3, SRID);
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, TYPE_HASZ(geom1->type));
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
 
+	PROFSTART(PROF_P2G1);
+
 	if (result == NULL)
 	{
 		GEOSGeom_destroy(g1);
@@ -592,17 +541,13 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-
-
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g3);
 
 	/* compressType(result);   */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, NULL, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, NULL, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 
@@ -619,30 +564,20 @@
 	int SRID;
 	BOX2DFLOAT4 bbox;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	SRID = pglwgeom_getSRID(geom1);
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSConvexHull(g1);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -656,13 +591,10 @@
 
 	GEOSSetSRID(g3, SRID);
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	lwout = GEOS2LWGEOM(g3, TYPE_HASZ(geom1->type));
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
+
 	if (lwout == NULL)
 	{
 		GEOSGeom_destroy(g1);
@@ -692,10 +624,8 @@
 
 	/* compressType(result);   */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, NULL, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, NULL, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 
@@ -759,9 +689,7 @@
 	PG_LWGEOM *result;
 	int quadsegs = 8; /* the default */
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	size = PG_GETARG_FLOAT8(1);
@@ -769,21 +697,13 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSBuffer(g1,size,quadsegs);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -792,18 +712,14 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-
 	POSTGIS_DEBUGF(3, "result: %s", GEOSGeomToWKT(g3));
 
 	GEOSSetSRID(g3, pglwgeom_getSRID(geom1));
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, TYPE_HASZ(geom1->type));
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
+
 	if (result == NULL)
 	{
 		GEOSGeom_destroy(g1);
@@ -817,10 +733,8 @@
 
 	/* compressType(result); */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, NULL, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, NULL, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 
@@ -837,9 +751,7 @@
 	int is3d;
 	int SRID;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -854,21 +766,13 @@
 
 	POSTGIS_DEBUG(3, "intersection() START");
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
 	POSTGIS_DEBUG(3, " constructed geometrys - calling geos");
 	POSTGIS_DEBUGF(3, " g1 = %s", GEOSGeomToWKT(g1));
@@ -876,13 +780,9 @@
 	/*POSTGIS_DEBUGF(3, "g2 is valid = %i",GEOSisvalid(g2)); */
 	/*POSTGIS_DEBUGF(3, "g1 is valid = %i",GEOSisvalid(g1)); */
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSIntersection(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	POSTGIS_DEBUG(3, " intersection finished");
 
@@ -898,13 +798,9 @@
 
 	GEOSSetSRID(g3, SRID);
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, is3d);
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
 
 	if (result == NULL)
 	{
@@ -919,10 +815,8 @@
 	GEOSGeom_destroy(g2);
 	GEOSGeom_destroy(g3);
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -945,9 +839,7 @@
 	int is3d;
 	int SRID;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -960,28 +852,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSDifference(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -995,13 +876,10 @@
 
 	GEOSSetSRID(g3, SRID);
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, is3d);
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
+
 	if (result == NULL)
 	{
 		GEOSGeom_destroy(g1);
@@ -1017,10 +895,8 @@
 
 	/* compressType(result); */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -1037,29 +913,19 @@
 	GEOSGeom g1,g3;
 	PG_LWGEOM *result;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSPointOnSurface(g1);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -1071,13 +937,11 @@
 	POSTGIS_DEBUGF(3, "result: %s", GEOSGeomToWKT(g3) ) ;
 
 	GEOSSetSRID(g3, pglwgeom_getSRID(geom1));
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, TYPE_HASZ(geom1->type));
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
+
 	if (result == NULL)
 	{
 		GEOSGeom_destroy(g1);
@@ -1091,10 +955,8 @@
 
 	/* compressType(result);  */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, NULL, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, NULL, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 
@@ -1107,29 +969,19 @@
 	PG_LWGEOM *geom, *result;
 	GEOSGeom geosgeom, geosresult;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	geosgeom = POSTGIS2GEOS(geom);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	geosresult = GEOSGetCentroid(geosgeom);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if ( geosresult == NULL )
 	{
@@ -1140,13 +992,10 @@
 
 	GEOSSetSRID(geosresult, pglwgeom_getSRID(geom));
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(geosresult, TYPE_HASZ(geom->type));
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
+
 	if (result == NULL)
 	{
 		GEOSGeom_destroy(geosgeom);
@@ -1157,10 +1006,8 @@
 	GEOSGeom_destroy(geosgeom);
 	GEOSGeom_destroy(geosresult);
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom, NULL, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom, NULL, result);
 
 	PG_FREE_IF_COPY(geom, 0);
 
@@ -1190,17 +1037,14 @@
 	bool result;
 	GEOSGeom g1;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
+
 	lwgeom = lwgeom_deserialize(SERIALIZED_FORM(geom1));
 	if ( ! lwgeom )
 	{
@@ -1213,17 +1057,12 @@
 		PG_RETURN_BOOL(FALSE);
 	}
 	lwgeom_release(lwgeom);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_GRUN);
 	result = GEOSisValid(g1);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	GEOSGeom_destroy(g1);
 	if (result == 2)
@@ -1232,12 +1071,9 @@
 		PG_RETURN_NULL(); /*never get here */
 	}
 
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, NULL, NULL);
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, NULL, NULL);
-#endif
-
 	PG_FREE_IF_COPY(geom1, 0);
 
 	PG_RETURN_BOOL(result);
@@ -1258,9 +1094,7 @@
 	bool result;
 	BOX2DFLOAT4 box1, box2;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -1284,28 +1118,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSOverlaps(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
@@ -1315,10 +1138,8 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -1676,9 +1497,7 @@
 	MemoryContext old_context;
 	RTREE_POLY_CACHE *poly_cache;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -1757,28 +1576,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSWithin(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
@@ -1789,10 +1597,8 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -1820,9 +1626,7 @@
 	RTREE_POLY_CACHE *poly_cache;
 	char *patt = "**F**F***";
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -1903,28 +1707,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSRelatePattern(g1,g2,patt);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
@@ -1935,10 +1728,8 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -1957,9 +1748,7 @@
 	bool result;
 	BOX2DFLOAT4 box1, box2;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -1984,28 +1773,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSCrosses(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
@@ -2016,10 +1794,8 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -2184,9 +1960,7 @@
 	bool result;
 	BOX2DFLOAT4 box1, box2;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -2211,28 +1985,17 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1 );
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2 );
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSTouches(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
@@ -2243,10 +2006,8 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -2264,9 +2025,7 @@
 	bool result;
 	BOX2DFLOAT4 box1, box2;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -2291,28 +2050,18 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSDisjoint(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
+
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
 
@@ -2322,10 +2071,8 @@
 		PG_RETURN_NULL(); /* never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -2460,9 +2207,7 @@
 	bool result;
 	BOX2DFLOAT4 box1, box2;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
@@ -2486,28 +2231,18 @@
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
-#ifdef PROFILE
-	profstart(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G1);
+
+	PROFSTART(PROF_P2G2);
 	g2 = POSTGIS2GEOS(geom2);
-#ifdef PROFILE
-	profstop(PROF_P2G2);
-#endif
+	PROFSTOP(PROF_P2G2);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	result = GEOSEquals(g1,g2);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
+
 	GEOSGeom_destroy(g1);
 	GEOSGeom_destroy(g2);
 
@@ -2517,10 +2252,8 @@
 		PG_RETURN_NULL(); /*never get here */
 	}
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, geom2, NULL);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, geom2, NULL);
 
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
@@ -3065,10 +2798,8 @@
 	geosgeom = POSTGIS2GEOS(geom);
 	if ( ! geosgeom ) PG_RETURN_NULL();
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-	profstop(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
+	PROFSTOP(PROF_GRUN);
 
 	lwgeom_result = GEOS2POSTGIS(geosgeom, TYPE_HASZ(geom->type));
 	GEOSGeom_destroy(geosgeom);
@@ -3174,29 +2905,19 @@
 	GEOSGeom g1,g3;
 	PG_LWGEOM *result;
 
-#ifdef PROFILE
-	profstart(PROF_QRUN);
-#endif
+	PROFSTART(PROF_QRUN);
 
 	geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
 	initGEOS(lwnotice, lwnotice);
 
-#ifdef PROFILE
-	profstart(PROF_P2G1);
-#endif
+	PROFSTART(PROF_P2G1);
 	g1 = POSTGIS2GEOS(geom1);
-#ifdef PROFILE
-	profstop(PROF_P2G1);
-#endif
+	PROFSTOP(PROF_P2G1);
 
-#ifdef PROFILE
-	profstart(PROF_GRUN);
-#endif
+	PROFSTART(PROF_GRUN);
 	g3 = GEOSLineMerge(g1);
-#ifdef PROFILE
-	profstop(PROF_GRUN);
-#endif
+	PROFSTOP(PROF_GRUN);
 
 	if (g3 == NULL)
 	{
@@ -3210,13 +2931,10 @@
 
 	GEOSSetSRID(g3, pglwgeom_getSRID(geom1));
 
-#ifdef PROFILE
-	profstart(PROF_G2P);
-#endif
+	PROFSTART(PROF_G2P);
 	result = GEOS2POSTGIS(g3, TYPE_HASZ(geom1->type));
-#ifdef PROFILE
-	profstop(PROF_G2P);
-#endif
+	PROFSTOP(PROF_G2P);
+
 	if (result == NULL)
 	{
 		GEOSGeom_destroy(g1);
@@ -3230,10 +2948,8 @@
 
 	/* compressType(result); */
 
-#ifdef PROFILE
-	profstop(PROF_QRUN);
-	profreport("geos",geom1, NULL, result);
-#endif
+	PROFSTOP(PROF_QRUN);
+	PROFREPORT("geos",geom1, NULL, result);
 
 	PG_FREE_IF_COPY(geom1, 0);
 

Modified: trunk/lwgeom/profile.h
===================================================================
--- trunk/lwgeom/profile.h	2008-11-20 13:42:00 UTC (rev 3306)
+++ trunk/lwgeom/profile.h	2008-11-20 15:00:57 UTC (rev 3307)
@@ -3,27 +3,27 @@
 
 #include <math.h>
 
-/*
- * Define this to have profiling enabled
- */
-/*#define PROFILE */
+/* Only enable profiling code if POSTGIS_PROFILE in postgis_config.h is > 0 */
+#if POSTGIS_PROFILE > 0
 
-#ifdef PROFILE
 #include <sys/time.h>
+
 #define PROF_P2G1 0
 #define PROF_P2G2 1
 #define PROF_G2P 2
 #define PROF_GRUN 3
 #define PROF_QRUN 4
+
 struct timeval profstart[5], profstop[5];
 long proftime[5];
 long profipts1, profipts2, profopts;
-#define profstart(x) do { gettimeofday(&(profstart[x]), NULL); } while (0);
-#define profstop(x) do { gettimeofday(&(profstop[x]), NULL); \
+
+#define PROFSTART(x) do { gettimeofday(&(profstart[x]), NULL); } while (0);
+#define PROFSTOP(x) do { gettimeofday(&(profstop[x]), NULL); \
 	proftime[x] = ( profstop[x].tv_sec*1000000+profstop[x].tv_usec) - \
 		( profstart[x].tv_sec*1000000+profstart[x].tv_usec); \
 	} while (0);
-#define profreport(n, i1, i2, o) do { \
+#define PROFREPORT(n, i1, i2, o) do { \
 	profipts1 = profipts2 = profopts = 0; \
 	if ((i1)) profipts1 += lwgeom_npoints(SERIALIZED_FORM((i1))); \
 	else proftime[PROF_P2G1] = 0; \
@@ -47,7 +47,14 @@
 		proftime[PROF_QRUN], \
 		runpercent+convpercent); \
 	} while (0);
-#endif /* PROFILE */
 
+#else
 
+/* Empty prototype that can be optimised away by the compiler for non-profiling builds */
+#define PROFSTART(x) ((void) 0)
+#define PROFSTOP(x) ((void) 0)
+#define PROFREPORT(n, i1, i2, o) ((void) 0)
+
+#endif /* POSTGIS_PROFILE */
+
 #endif /* _PROFILE_H */

Modified: trunk/postgis_config.h.in
===================================================================
--- trunk/postgis_config.h.in	2008-11-20 13:42:00 UTC (rev 3306)
+++ trunk/postgis_config.h.in	2008-11-20 15:00:57 UTC (rev 3307)
@@ -1,5 +1,8 @@
-/* postgis_config.h.in.  Generated from configure.in by autoheader.  */
+/* postgis_config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
 /* Defined if libiconv headers and library are present */
 #undef HAVE_ICONV
 
@@ -54,9 +57,21 @@
 /* PostGIS library version */
 #undef POSTGIS_LIB_VERSION
 
+/* PostGIS major version */
+#undef POSTGIS_MAJOR_VERSION
+
+/* PostGIS micro version */
+#undef POSTGIS_MICRO_VERSION
+
+/* PostGIS minor version */
+#undef POSTGIS_MINOR_VERSION
+
 /* PostgreSQL server version */
 #undef POSTGIS_PGSQL_VERSION
 
+/* Enable GEOS profiling (0=disabled) */
+#undef POSTGIS_PROFILE
+
 /* PROJ library version */
 #undef POSTGIS_PROJ_VERSION
 
@@ -71,3 +86,7 @@
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+   `char[]'. */
+#undef YYTEXT_POINTER



More information about the postgis-commits mailing list