From: Adam Dickmeiss Date: Tue, 12 Dec 2006 13:42:23 +0000 (+0000) Subject: Added statistics functions dict_get_no_{lookup,insert,split}. X-Git-Tag: ZEBRA.2.0.8~36 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=883a7ce6ae98a97520d62038acca2612cb582836;p=idzebra-moved-to-github.git Added statistics functions dict_get_no_{lookup,insert,split}. --- diff --git a/dict/dict-p.h b/dict/dict-p.h index 64b4082..e50fff8 100644 --- a/dict/dict-p.h +++ b/dict/dict-p.h @@ -1,4 +1,4 @@ -/* $Id: dict-p.h,v 1.7 2006-08-29 11:28:42 adam Exp $ +/* $Id: dict-p.h,v 1.8 2006-12-12 13:42:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -77,6 +77,12 @@ struct Dict_struct { Dict_BFile dbf; const char **(*grep_cmap)(void *vp, const char **from, int len); void *grep_cmap_data; + /** number of split page operations, since dict_open */ + zint no_split; + /** number of insert operations, since dict_open */ + zint no_insert; + /** number of lookup operations, since dict_open */ + zint no_lookup; struct Dict_head head; }; diff --git a/dict/insert.c b/dict/insert.c index bdc1857..8ac1d5a 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -1,4 +1,4 @@ -/* $Id: insert.c,v 1.29 2006-11-14 12:04:38 adam Exp $ +/* $Id: insert.c,v 1.30 2006-12-12 13:42:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -74,6 +74,7 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p) Dict_char prev_char = 0; int best_no = -1, no_current = 1; + dict->no_split++; /* determine splitting char... */ indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); for (i = DICT_nodir (p); --i >= 0; --indxp) @@ -438,6 +439,7 @@ int dict_insert (Dict dict, const char *str, int userlen, void *userinfo) { if (!dict->rw) return -1; + dict->no_insert++; if (!dict->head.root) { void *p; diff --git a/dict/lookup.c b/dict/lookup.c index 82789fc..7704482 100644 --- a/dict/lookup.c +++ b/dict/lookup.c @@ -1,4 +1,4 @@ -/* $Id: lookup.c,v 1.15 2006-08-14 10:40:09 adam Exp $ +/* $Id: lookup.c,v 1.16 2006-12-12 13:42:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -99,6 +99,7 @@ static char *dict_look (Dict dict, const Dict_char *str, Dict_ptr ptr) char *dict_lookup (Dict dict, const char *p) { + dict->no_lookup++; if (!dict->head.root) return NULL; return dict_look (dict, (const Dict_char *) p, dict->head.root); diff --git a/dict/open.c b/dict/open.c index 0db5336..f7623b0 100644 --- a/dict/open.c +++ b/dict/open.c @@ -1,4 +1,4 @@ -/* $Id: open.c,v 1.27 2006-09-11 22:57:54 adam Exp $ +/* $Id: open.c,v 1.28 2006-12-12 13:42:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -68,6 +68,9 @@ Dict dict_open (BFiles bfs, const char *name, int cache, int rw, } dict->dbf = dict_bf_open (bfs, name, page_size, cache, rw); dict->rw = rw; + dict->no_split = 0; + dict->no_insert = 0; + dict->no_lookup = 0; if(!dict->dbf) { @@ -116,6 +119,22 @@ int dict_strlen (const Dict_char *s) { return strlen((const char *) s); } + +zint dict_get_no_lookup(Dict dict) +{ + return dict->no_lookup; +} + +zint dict_get_no_insert(Dict dict) +{ + return dict->no_insert; +} + +zint dict_get_no_split(Dict dict) +{ + return dict->no_split; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/include/idzebra/dict.h b/include/idzebra/dict.h index 6691142..8d1edf2 100644 --- a/include/idzebra/dict.h +++ b/include/idzebra/dict.h @@ -1,4 +1,4 @@ -/* $Id: dict.h,v 1.12 2006-09-11 22:57:54 adam Exp $ +/* $Id: dict.h,v 1.13 2006-12-12 13:42:23 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -193,6 +193,26 @@ int dict_copy_compact(BFiles bfs, const char *from, const char *to); YAZ_EXPORT void dict_clean(Dict dict); +/** \brief get number of lookup operations, since dict_open + \param dict dictionary handle + \returns number of operatons +*/ +YAZ_EXPORT +zint dict_get_no_lookup(Dict dict); + +/** \brief get number of insert operations, since dict_open + \param dict dictionary handle + \returns number of operatons +*/ +YAZ_EXPORT +zint dict_get_no_insert(Dict dict); + +/** \brief get number of page split operations, since dict_open + \param dict dictionary handle + \returns number of operatons +*/ +YAZ_EXPORT +zint dict_get_no_split(Dict dict); YAZ_END_CDECL