23 #include <yaz/options.h>
25 #include <sys/times.h>
34 #include <yaz/xmalloc.h>
35 #include <yaz/timing.h>
39 static void log_item(
int level,
const void *b,
const char *txt)
42 memcpy(&x, b,
sizeof(
int));
43 yaz_log(YLOG_LOG,
"%s %d", txt, x);
48 yaz_log(YLOG_LOG,
"%s", txt);
55 memcpy(&ia, (
const char *) a + 1,
sizeof(
int));
56 memcpy(&ib, (
const char *) b + 1,
sizeof(
int));
69 void code_item(
void *p,
char **dst,
const char **src)
72 memcpy (*dst, *src, sz);
94 int code_read(
void *vp,
char **dst,
int *insertMode)
99 if (ri->
no >= ri->
max)
104 memset(*dst, 0, ri->
sz);
106 memcpy(*dst + 1, &x,
sizeof(
int));
114 yaz_log(YLOG_LOG,
"%d %5d", ri->
insertMode, x);
120 int number_of_rounds,
int number_of_elements,
124 ISAM_P *isamc_p = xmalloc(
sizeof(
ISAM_P) * number_of_trees);
128 for (i = 0; i<number_of_trees; i++)
134 ri.
sz =
sizeof(int) + 1 + extra_size;
136 for (round = 0; round < number_of_rounds; round++)
138 yaz_timing_t t = yaz_timing_create();
141 for (i = 0; i<number_of_trees; i++)
148 if (RAND_MAX < 65536)
149 ri.
val = ri.
val + 65536*rand();
152 ri.
max = number_of_elements;
163 printf(
"%3d %8.6f %5.2f %5.2f\n",
165 yaz_timing_get_real(t),
166 yaz_timing_get_user(t),
167 yaz_timing_get_sys(t));
168 yaz_timing_destroy(&t);
175 fprintf(stderr,
"benchisamb [-r rounds] [-n items] [-i isams]\n");
179 int main(
int argc,
char **argv)
186 int number_of_rounds = 10;
187 int number_of_items = 1000;
188 int number_of_isams = 1000;
192 while ((ret = options(
"z:r:n:i:", argv, argc, &arg)) != -2)
197 number_of_rounds = atoi(arg);
200 number_of_items = atoi(arg);
203 number_of_isams = atoi(arg);
206 extra_size = atoi(arg);
209 fprintf(stderr,
"bad arg: %s\n", arg);
212 fprintf(stderr,
"bad option.\n");
226 t = yaz_timing_create();
234 yaz_log(YLOG_WARN,
"bfs_create failed");
241 isb =
isamb_open (bfs,
"isamb", 1, &method, 0);
244 yaz_log(YLOG_WARN,
"isamb_open failed");
247 bench_insert(isb, number_of_isams, number_of_rounds, number_of_items,
256 printf(
"Total %8.6f %5.2f %5.2f\n",
257 yaz_timing_get_real(t),
258 yaz_timing_get_user(t),
259 yaz_timing_get_sys(t));
260 yaz_timing_destroy(&t);
static void log_item(int level, const void *b, const char *txt)
int main(int argc, char **argv)
int compare_item(const void *a, const void *b)
void code_item(void *p, char **dst, const char **src)
static void log_pr(const char *txt)
void bench_insert(ISAMB isb, int number_of_trees, int number_of_rounds, int number_of_elements, int extra_size)
int code_read(void *vp, char **dst, int *insertMode)
void bf_reset(BFiles bfs)
Removes register and shadow completely.
BFiles bfs_create(const char *spec, const char *base)
creates a Block files collection
void bfs_destroy(BFiles bfiles)
destroys a block files handle
ISAMB isamb_open(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, int cache)
void isamb_dump(ISAMB b, ISAM_P pos, void(*pr)(const char *str))
void isamb_close(ISAMB isamb)
void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data)
int(* read_item)(void *clientData, char **dst, int *insertMode)
int(* compare_item)(const void *a, const void *b)
void(* log_item)(int logmask, const void *p, const char *txt)
void(* decode)(void *p, char **dst, const char **src)
void(* encode)(void *p, char **dst, const char **src)