X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=isamb%2Ftstisamb.c;h=4103211742341c54d93e550893b22907e5128ba7;hb=4eaf00a0af4c40bd166e2224964319a58efafeaa;hp=d8150899c8d004671fb35eb41f0ad58f0794ec8e;hpb=ecf94fc25324414287d3bbfbeba4440e558edd17;p=idzebra-moved-to-github.git diff --git a/isamb/tstisamb.c b/isamb/tstisamb.c index d815089..4103211 100644 --- a/isamb/tstisamb.c +++ b/isamb/tstisamb.c @@ -1,5 +1,5 @@ -/* $Id: tstisamb.c,v 1.20 2005-04-13 13:03:48 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: tstisamb.c,v 1.26 2006-12-07 21:13:56 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -15,11 +15,18 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#if HAVE_SYS_TIMES_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif + #include #include #include @@ -52,7 +59,7 @@ int compare_item(const void *a, const void *b) return 0; } -void *code_start() +void *code_start(void) { return 0; } @@ -72,8 +79,10 @@ void code_stop(void *p) } struct read_info { - int no; + int val; int step; + + int no; int max; int insertMode; }; @@ -85,28 +94,95 @@ int code_read(void *vp, char **dst, int *insertMode) if (ri->no >= ri->max) return 0; - x = ri->no; + ri->no++; + + x = ri->val; memcpy (*dst, &x, sizeof(int)); (*dst)+=sizeof(int); - ri->no = ri->no + ri->step; + ri->val = ri->val + ri->step; *insertMode = ri->insertMode; + +#if 0 + yaz_log(YLOG_LOG, "%d %5d", ri->insertMode, x); +#endif return 1; } +void bench_insert(ISAMB isb, int number_of_trees, + int number_of_rounds, int number_of_elements) +{ + ISAMC_I isamc_i; + ISAM_P *isamc_p = xmalloc(sizeof(ISAM_P) * number_of_trees); + struct read_info ri; + int round, i; + + for (i = 0; iidx < ri->max && ri->delta[ri->idx] == ri->level) + { + ri->idx++; + ri->level = 0; + } + if (ri->idx >= ri->max) + return 0; + + if (ri->delta[ri->idx] > 0) + { + ri->level++; + *insertMode = 1; + } + else + { + ri->level--; + *insertMode = 0; + } + x = ri->idx; + memcpy (*dst, &x, sizeof(int)); + (*dst)+=sizeof(int); + + yaz_log(YLOG_DEBUG, "%d %5d", *insertMode, x); + return 1; +} + +void tst_random(ISAMB isb, int n, int rounds, int max_dups) +{ + ISAM_P isamb_p = 0; + + int *freq = malloc(sizeof(int) * n); + int *delta = malloc(sizeof(int) * n); + int i, j; + for (i = 0; i