X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=isamb%2Fbenchisamb.c;h=a726e6234eea1196f693041347e0d865efb56462;hp=f252a4fdae34c50c5ea08181c2e49166018fe8c2;hb=cc7fe6c74481b36e6467054a3e72b8e3295105a6;hpb=3c5356c1ac5cb9bfb33a3e61d2b1a7db6e7615db diff --git a/isamb/benchisamb.c b/isamb/benchisamb.c index f252a4f..a726e62 100644 --- a/isamb/benchisamb.c +++ b/isamb/benchisamb.c @@ -1,8 +1,5 @@ -/* $Id: benchisamb.c,v 1.1 2006-12-09 08:03:57 adam Exp $ - Copyright (C) 1995-2006 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -20,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #if HAVE_SYS_TIMES_H #include @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include @@ -51,8 +52,8 @@ int compare_item(const void *a, const void *b) { int ia, ib; - memcpy(&ia, a, sizeof(int)); - memcpy(&ib, b, sizeof(int)); + memcpy(&ia, (const char *) a + 1, sizeof(int)); + memcpy(&ib, (const char *) b + 1, sizeof(int)); if (ia > ib) return 1; if (ia < ib) @@ -67,9 +68,10 @@ void *code_start(void) void code_item(void *p, char **dst, const char **src) { - memcpy (*dst, *src, sizeof(int)); - (*dst) += sizeof(int); - (*src) += sizeof(int); + int sz = **src; + memcpy (*dst, *src, sz); + (*dst) += sz; + (*src) += sz; } void code_reset(void *p) @@ -86,6 +88,7 @@ struct read_info { int no; int max; int insertMode; + int sz; }; int code_read(void *vp, char **dst, int *insertMode) @@ -98,8 +101,11 @@ int code_read(void *vp, char **dst, int *insertMode) ri->no++; x = ri->val; - memcpy (*dst, &x, sizeof(int)); - (*dst)+=sizeof(int); + memset(*dst, 0, ri->sz); + **dst = ri->sz; + memcpy(*dst + 1, &x, sizeof(int)); + + (*dst) += ri->sz; ri->val = ri->val + ri->step; *insertMode = ri->insertMode; @@ -111,7 +117,8 @@ int code_read(void *vp, char **dst, int *insertMode) } void bench_insert(ISAMB isb, int number_of_trees, - int number_of_rounds, int number_of_elements) + int number_of_rounds, int number_of_elements, + int extra_size) { ISAMC_I isamc_i; ISAM_P *isamc_p = xmalloc(sizeof(ISAM_P) * number_of_trees); @@ -124,25 +131,23 @@ void bench_insert(ISAMB isb, int number_of_trees, ri.val = 0; ri.step = 1; ri.insertMode = 1; + ri.sz = sizeof(int) + 1 + extra_size; for (round = 0; round < number_of_rounds; round++) { -#if HAVE_SYS_TIMES_H -#if HAVE_SYS_TIME_H - struct tms tms1, tms2; - struct timeval start_time, end_time; - double usec; - times(&tms1); - gettimeofday(&start_time, 0); -#endif -#endif + yaz_timing_t t = yaz_timing_create(); + + yaz_timing_start(t); for (i = 0; i