aboutsummaryrefslogtreecommitdiffstats
path: root/libibex/hash.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-10-12 21:40:55 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-10-12 21:40:55 +0800
commit1deca02b41aae9bf2632ea1420cc900fcf41531d (patch)
treee26816ec82c3990801aca2a35686d5df2ba00957 /libibex/hash.c
parent6c337e9ea0623b48688c018973d35823dde21f60 (diff)
downloadgsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.tar
gsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.tar.gz
gsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.tar.bz2
gsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.tar.lz
gsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.tar.xz
gsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.tar.zst
gsoc2013-evolution-1deca02b41aae9bf2632ea1420cc900fcf41531d.zip
Added some stat stuff.
2000-10-12 Not Zed <NotZed@HelixCode.com> * index.h: Added some stat stuff. * wordindex.c (struct _wordcache): Changed files[] to be a pointer to an allocated block/or an individual item. (find): Fix for changes to struct. (find_name): " (sync_cache_entry): " (add): " (add_list): " (add_index_cache): Free the cache file array if it was created. (word_flush): And here. (word_close): And here too. (ibex_create_word_index): Double the size of the hashtables. (word_flush): Make sure we reset the wordcount to 0 if we remove the list items. DOH. (add_index_cache): Use a slightly more sohpisticated aging algorithm to remove expired nodes. 2000-10-10 Not Zed <NotZed@HelixCode.com> * hash.c (hash_find): (hash_remove): (hash_insert): Truncate key if it is too big to fit in a single block to MAX_KEYLEN bytes. svn path=/trunk/; revision=5882
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 */