From 3c5356c1ac5cb9bfb33a3e61d2b1a7db6e7615db Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 9 Dec 2006 08:03:57 +0000 Subject: [PATCH] Added some performance test utilities. --- isamb/.cvsignore | 3 + isamb/Makefile.am | 10 ++- isamb/bench1.plt | 8 ++ isamb/bench1.sh | 13 +++ isamb/benchisamb.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++++ isamb/tstisamb.c | 75 ++-------------- 6 files changed, 293 insertions(+), 69 deletions(-) create mode 100644 isamb/bench1.plt create mode 100755 isamb/bench1.sh create mode 100644 isamb/benchisamb.c diff --git a/isamb/.cvsignore b/isamb/.cvsignore index 1a309ec..2f5499e 100644 --- a/isamb/.cvsignore +++ b/isamb/.cvsignore @@ -4,5 +4,8 @@ Makefile Makefile.in *.mf tstisamb +benchisamb *.lo *.la +*.dat +*.eps diff --git a/isamb/Makefile.am b/isamb/Makefile.am index eb89f4c..1624001 100644 --- a/isamb/Makefile.am +++ b/isamb/Makefile.am @@ -1,9 +1,12 @@ -## $Id: Makefile.am,v 1.13 2006-07-05 15:03:48 adam Exp $ +## $Id: Makefile.am,v 1.14 2006-12-09 08:03:57 adam Exp $ noinst_LTLIBRARIES = libidzebra-isamb.la +noinst_PROGRAMS = benchisamb check_PROGRAMS = tstisamb +EXTRA_DIST = bench1.sh bench1.plt + TESTS = $(check_PROGRAMS) tstisamb_SOURCES = tstisamb.c @@ -11,6 +14,11 @@ tstisamb_LDADD = libidzebra-isamb.la \ ../bfile/libidzebra-bfile.la \ ../util/libidzebra-util.la $(YAZLALIB) +benchisamb_SOURCES = benchisamb.c +benchisamb_LDADD = libidzebra-isamb.la \ + ../bfile/libidzebra-bfile.la \ + ../util/libidzebra-util.la $(YAZLALIB) + libidzebra_isamb_la_SOURCES = isamb.c AM_CPPFLAGS=-I$(srcdir)/../include $(YAZINC) diff --git a/isamb/bench1.plt b/isamb/bench1.plt new file mode 100644 index 0000000..a6c3f35 --- /dev/null +++ b/isamb/bench1.plt @@ -0,0 +1,8 @@ +set terminal postscript eps +set output "bench1.eps" +set xlabel "R" +set ylabel "time" +plot "1000x1000.dat" title "isam 1000" with linespoints, \ + "100x10000.dat" title "isam 100" with linespoints, \ + "10x100000.dat" title "isam 10" with linespoints, \ + "1x1000000.dat" title "isam 1" with linespoints diff --git a/isamb/bench1.sh b/isamb/bench1.sh new file mode 100755 index 0000000..1a91cd3 --- /dev/null +++ b/isamb/bench1.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# $Id: bench1.sh,v 1.1 2006-12-09 08:03:57 adam Exp $ +# Test for variations of number of trees.. Total number of entries is +# Constant 1 mio +CMD="./benchisamb -r 50" + +$CMD -i 1000 -n 1000 >1000x1000.dat +sleep 2 +$CMD -i 100 -n 10000 >100x10000.dat +sleep 2 +$CMD -i 10 -n 100000 >10x100000.dat +sleep 2 +$CMD -i 1 -n 1000000 >1x1000000.dat diff --git a/isamb/benchisamb.c b/isamb/benchisamb.c new file mode 100644 index 0000000..f252a4f --- /dev/null +++ b/isamb/benchisamb.c @@ -0,0 +1,253 @@ +/* $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. + +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 +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +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 this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include +#if HAVE_SYS_TIMES_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +static void log_item(int level, const void *b, const char *txt) +{ + int x; + memcpy(&x, b, sizeof(int)); + yaz_log(YLOG_LOG, "%s %d", txt, x); +} + +static void log_pr(const char *txt) +{ + yaz_log(YLOG_LOG, "%s", txt); +} + +int compare_item(const void *a, const void *b) +{ + int ia, ib; + + memcpy(&ia, a, sizeof(int)); + memcpy(&ib, b, sizeof(int)); + if (ia > ib) + return 1; + if (ia < ib) + return -1; + return 0; +} + +void *code_start(void) +{ + return 0; +} + +void code_item(void *p, char **dst, const char **src) +{ + memcpy (*dst, *src, sizeof(int)); + (*dst) += sizeof(int); + (*src) += sizeof(int); +} + +void code_reset(void *p) +{ +} +void code_stop(void *p) +{ +} + +struct read_info { + int val; + int step; + + int no; + int max; + int insertMode; +}; + +int code_read(void *vp, char **dst, int *insertMode) +{ + struct read_info *ri = (struct read_info *)vp; + int x; + + if (ri->no >= ri->max) + return 0; + ri->no++; + + x = ri->val; + memcpy (*dst, &x, sizeof(int)); + (*dst)+=sizeof(int); + + 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; i #include +static int log_level = 0; + static void log_item(int level, const void *b, const char *txt) { int x; memcpy(&x, b, sizeof(int)); - yaz_log(YLOG_DEBUG, "%s %d", txt, x); + yaz_log(log_level, "%s %d", txt, x); } static void log_pr(const char *txt) { - yaz_log(YLOG_DEBUG, "%s", txt); + yaz_log(log_level, "%s", txt); } int compare_item(const void *a, const void *b) @@ -104,70 +106,11 @@ int code_read(void *vp, char **dst, int *insertMode) *insertMode = ri->insertMode; #if 0 - yaz_log(YLOG_LOG, "%d %5d", ri->insertMode, x); + yaz_log(log_level, "%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; i