X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=isamb%2Ftstisamb.c;h=4103211742341c54d93e550893b22907e5128ba7;hb=4eaf00a0af4c40bd166e2224964319a58efafeaa;hp=67e3336463ec8fd5fc6745aab39495fbe42c2f20;hpb=4eb3b54bb2ca9af74f39f000d3d40dba99ded887;p=idzebra-moved-to-github.git diff --git a/isamb/tstisamb.c b/isamb/tstisamb.c index 67e3336..4103211 100644 --- a/isamb/tstisamb.c +++ b/isamb/tstisamb.c @@ -1,6 +1,6 @@ -/* $Id: tstisamb.c,v 1.13 2004-12-13 20:51:31 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 - Index Data Aps +/* $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,19 @@ 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 #include @@ -44,10 +52,14 @@ int compare_item(const void *a, const void *b) memcpy(&ia, a, sizeof(int)); memcpy(&ib, b, sizeof(int)); - return ia - ib; + if (ia > ib) + return 1; + if (ia < ib) + return -1; + return 0; } -void *code_start() +void *code_start(void) { return 0; } @@ -67,8 +79,10 @@ void code_stop(void *p) } struct read_info { - int no; + int val; int step; + + int no; int max; int insertMode; }; @@ -80,36 +94,191 @@ 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->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; - isamc_p = isamb_merge (isb, 0 /* new list */ , &isamc_i); + 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); - /* read the entries */ - pp = isamb_pp_open (isb, isamc_p, 2); + 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