From: Kaj-Michael Lang Date: Mon, 5 May 2008 09:21:33 +0000 (+0300) Subject: Add query timing helper macros X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b38112801ac61a0b0645cefb2c5288efc7a7e34;p=mapper Add query timing helper macros --- diff --git a/src/osm-db.c b/src/osm-db.c index 01e7674..385a3e1 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -38,7 +38,7 @@ #include "osm-sql-tables.h" /* #define DEBUG_OSM */ -/* #define DEBUG_OSM_TIME */ +#define DEBUG_OSM_TIME #define OSM_PLACE_CACHE_MAX_ITEMS (64) #define OSM_DB_PROGRESS_NUM (30000) @@ -51,6 +51,14 @@ /* Way range for searching again */ #define OSM_RANGE_WAY (12000) +#ifdef DEBUG_OSM_TIME +#define QT_START { g_timer_start(dbt); } +#define QT_END { g_timer_stop(dbt); g_debug("Query took: %f sec", g_timer_elapsed(dbt, &tms)); } +#else +#define QT_START +#define QT_END +#endif + static sqlite3 *osmdb; static gboolean osm_db_ok; @@ -74,6 +82,7 @@ struct sql_select_stmt { }; static struct sql_select_stmt sql; static GTimer *dbt; +static gulong tms; static GtkProgressBar *dbpw=NULL; static const gchar *osm_tables[]={ @@ -529,6 +538,7 @@ if (SQLITE_OK != sqlite3_bind_int(sql.select_place, 1, lat) || return FALSE; } +QT_START if (SQLITE_ROW == sqlite3_step(sql.select_place)) { const gchar *place; guint32 dist; @@ -545,6 +555,7 @@ if (SQLITE_ROW == sqlite3_step(sql.select_place)) { /* n->isin_c=sqlite3_column_int(sql.select_place, 6); */ return TRUE; } +QT_END return FALSE; } @@ -589,6 +600,7 @@ if (SQLITE_OK != sqlite3_bind_int(sql.select_place_near, 1, lat) || n=osm_place_new(); n->isin_p=n->lat=n->lon=n->dist=0; +QT_START if (SQLITE_ROW == sqlite3_step(sql.select_place_near)) { const gchar *place; guint32 dist; @@ -604,6 +616,7 @@ if (SQLITE_ROW == sqlite3_step(sql.select_place_near)) { /* n->isin_c=sqlite3_column_int(sql.select_place_near, 6); */ n->type=type; + QT_END osm_place_cache_add(n); *nr=n; @@ -622,7 +635,6 @@ osm_find_nearest_way_nodes(gint lat, gint lon, guint range) { GList *ways=NULL; osm_way *w; -gulong tms; guint wc=0; g_return_val_if_fail(sql.select_way2, NULL); @@ -639,10 +651,7 @@ if (SQLITE_OK != sqlite3_bind_int(sql.select_way2, 1, lat) || return NULL; } -#ifdef DEBUG_OSM_TIME -g_timer_start(dbt); -#endif - +QT_START while (SQLITE_ROW == sqlite3_step(sql.select_way2)) { guint32 dist; gint lat, lon; @@ -665,11 +674,7 @@ while (SQLITE_ROW == sqlite3_step(sql.select_way2)) { ways=g_list_prepend(ways, w); } - -#ifdef DEBUG_OSM_TIME -g_timer_stop(dbt); -g_debug("Query took: %f sec, found: %d ways", g_timer_elapsed(dbt, &tms), wc); -#endif +QT_END return ways; }