aboutsummaryrefslogtreecommitdiffstats
path: root/libibex/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'libibex/hash.c')
-rw-r--r--libibex/hash.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libibex/hash.c b/libibex/hash.c
index a36bef33b0..25a6e92ef9 100644
--- a/libibex/hash.c
+++ b/libibex/hash.c
@@ -190,6 +190,9 @@ static int hash_sync(struct _IBEXIndex *index)
static int hash_close(struct _IBEXIndex *index)
{
+#ifdef INDEX_STAT
+ printf("Performed %d lookups, average %f depth\n", index->lookups, (double)index->lookup_total/index->lookups);
+#endif
g_free(index);
return 0;
}
@@ -259,12 +262,19 @@ hash_find(struct _IBEXIndex *index, const char *key, int keylen)
/* and its bucket */
hashbucket = table->buckets[hashentry];
+#ifdef INDEX_STAT
+ index->lookups++;
+#endif
/* go down the bucket chain, reading each entry till we are done ... */
while (hashbucket != 0) {
struct _hashblock *bucket;
char *start, *end;
int ind;
+#ifdef INDEX_STAT
+ index->lookup_total++;
+#endif
+
d(printf(" checking bucket %d\n", hashbucket));
/* get the real bucket id from the hashbucket id */