From ae5c8868f2bee81cebddf3251432eb47c3da3591 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 5 Jan 2007 10:45:11 +0000 Subject: [PATCH] Removed zebra_timing_t. Using yaz_timing_t instead. Requires YAZ 2.1.45. --- configure.ac | 6 +-- include/idzebra/util.h | 19 +-------- index/index.h | 5 ++- index/kinput.c | 4 +- index/zebraapi.c | 14 +++--- isamb/benchindex1.c | 47 ++++++++++---------- isamb/benchisamb.c | 33 +++++++------- util/Makefile.am | 4 +- util/timing.c | 111 ------------------------------------------------ 9 files changed, 59 insertions(+), 184 deletions(-) delete mode 100644 util/timing.c diff --git a/configure.ac b/configure.ac index 73845d8..ab6ef9e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl Zebra, Index Data ApS, 1995-2006 -dnl $Id: configure.ac,v 1.43 2006-12-22 12:13:39 adam Exp $ +dnl $Id: configure.ac,v 1.44 2007-01-05 10:45:11 adam Exp $ dnl AC_PREREQ(2.59) AC_INIT([idzebra],[2.0.7],[zebra-help@indexdata.dk]) @@ -25,7 +25,7 @@ AC_PROG_CPP AM_PROG_LIBTOOL dnl dnl ------ headers -AC_CHECK_HEADERS(sys/resource.h sys/times.h sys/time.h sys/wait.h sys/utsname.h unistd.h) +AC_CHECK_HEADERS(sys/resource.h sys/time.h sys/wait.h sys/utsname.h unistd.h) dnl ------ crypt AC_CHECK_LIB(crypt, crypt) if test "$ac_cv_lib_crypt_crypt" = "yes"; then @@ -41,7 +41,7 @@ else fi dnl dnl ------ YAZ -YAZ_INIT($yazflag,2.1.40) +YAZ_INIT($yazflag,2.1.45) if test "$YAZVERSION" = "NONE"; then AC_MSG_ERROR([YAZ development libraries required]) fi diff --git a/include/idzebra/util.h b/include/idzebra/util.h index 831ef3f..7cc4512 100644 --- a/include/idzebra/util.h +++ b/include/idzebra/util.h @@ -1,4 +1,4 @@ -/* $Id: util.h,v 1.13 2006-12-22 13:48:20 adam Exp $ +/* $Id: util.h,v 1.14 2007-01-05 10:45:11 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -99,23 +99,6 @@ YAZ_EXPORT void zebra_zint_decode(const char **src, zint *pos); YAZ_EXPORT void zebra_exit(const char *msg); -typedef struct zebra_timing *zebra_timing_t; - -YAZ_EXPORT -zebra_timing_t zebra_timing_create(void); -YAZ_EXPORT -void zebra_timing_start(zebra_timing_t t); -YAZ_EXPORT -void zebra_timing_stop(zebra_timing_t t); -YAZ_EXPORT -double zebra_timing_get_real(zebra_timing_t t); -YAZ_EXPORT -double zebra_timing_get_user(zebra_timing_t t); -YAZ_EXPORT -double zebra_timing_get_sys(zebra_timing_t t); -YAZ_EXPORT -void zebra_timing_destroy(zebra_timing_t *tp); - YAZ_EXPORT zint atozint(const char *src); YAZ_END_CDECL diff --git a/index/index.h b/index/index.h index 46c4c09..0cfe657 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.188 2006-12-22 12:14:25 adam Exp $ +/* $Id: index.h,v 1.189 2007-01-05 10:45:11 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include +#include #include #include #include @@ -167,7 +168,7 @@ struct zebra_service { const char *path_root; RecTypeClass record_classes; NMEM nmem; - zebra_timing_t timing; + yaz_timing_t timing; }; diff --git a/index/kinput.c b/index/kinput.c index 44c44ea..17c6d9f 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -1,4 +1,4 @@ -/* $Id: kinput.c,v 1.80 2006-12-06 22:52:38 adam Exp $ +/* $Id: kinput.c,v 1.81 2007-01-05 10:45:11 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -55,7 +55,7 @@ struct key_file { Res res; }; -#if 1 +#if 0 static void pkey(const char *b, int mode) { key_logdump_txt(YLOG_LOG, b, mode ? "i" : "d"); diff --git a/index/zebraapi.c b/index/zebraapi.c index 1b424e3..dc01daf 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.240 2006-12-22 12:14:25 adam Exp $ +/* $Id: zebraapi.c,v 1.241 2007-01-05 10:45:12 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -258,7 +258,7 @@ ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) } } - zh->timing = zebra_timing_create(); + zh->timing = yaz_timing_create(); zh->path_root = res_get (zh->global_res, "root"); zh->nmem = nmem_create(); zh->record_classes = recTypeClass_create (zh->global_res, zh->nmem); @@ -596,14 +596,14 @@ ZEBRA_RES zebra_stop(ZebraService zs) nmem_destroy(zs->nmem); res_close (zs->global_res); - zebra_timing_stop(zs->timing); + yaz_timing_stop(zs->timing); yaz_log (YLOG_LOG, "zebra_stop: %4.2f %4.2f %4.2f", - zebra_timing_get_real(zs->timing), - zebra_timing_get_user(zs->timing), - zebra_timing_get_sys(zs->timing)); + yaz_timing_get_real(zs->timing), + yaz_timing_get_user(zs->timing), + yaz_timing_get_sys(zs->timing)); - zebra_timing_destroy(&zs->timing); + yaz_timing_destroy(&zs->timing); xfree(zs); return ZEBRA_OK; } diff --git a/isamb/benchindex1.c b/isamb/benchindex1.c index 1ba900c..fc0e222 100644 --- a/isamb/benchindex1.c +++ b/isamb/benchindex1.c @@ -1,4 +1,4 @@ -/* $Id: benchindex1.c,v 1.7 2006-12-12 17:33:35 adam Exp $ +/* $Id: benchindex1.c,v 1.8 2007-01-05 10:45:12 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include #include @@ -130,8 +131,8 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, int no_words = 0, no_new_words = 0; const char *dict_info = 0; ISAM_P isamc_p = 0; - zebra_timing_t tim_dict = 0; - zebra_timing_t tim_isamb = 0; + yaz_timing_t tim_dict = 0; + yaz_timing_t tim_isamb = 0; zint number_of_int_splits = isamb_get_int_splits(isb); zint number_of_leaf_splits = isamb_get_leaf_splits(isb); zint number_of_dict_splits = dict_get_no_split(dict); @@ -145,7 +146,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, assert(!t); qsort(b->ar, b->no_entries, sizeof(*b->ar), cmp_ar); - tim_dict = zebra_timing_create(); + tim_dict = yaz_timing_create(); #if 0 for (i = 0; i < b->no_entries; i++) { @@ -190,8 +191,8 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, } dict_insert(dict, "_w", sizeof(word_id_seq), &word_id_seq); - zebra_timing_stop(tim_dict); - tim_isamb = zebra_timing_create(); + yaz_timing_stop(tim_dict); + tim_isamb = yaz_timing_create(); b->current_entry = 0; @@ -208,7 +209,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, dict_insert(dict, "_i", sizeof(isamc_p), &isamc_p); } - zebra_timing_stop(tim_isamb); + yaz_timing_stop(tim_isamb); number_of_int_splits = isamb_get_int_splits(isb) - number_of_int_splits; number_of_leaf_splits = isamb_get_leaf_splits(isb) - number_of_leaf_splits; @@ -224,13 +225,13 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, "%6" ZINT_FORMAT0 " %6" ZINT_FORMAT0 " %8d %8d %6d %6d" " %5" ZINT_FORMAT0 "\n", b->round, - zebra_timing_get_real(tim_dict) + zebra_timing_get_real(tim_isamb), - zebra_timing_get_real(tim_dict), - zebra_timing_get_user(tim_dict), - zebra_timing_get_sys(tim_dict), - zebra_timing_get_real(tim_isamb), - zebra_timing_get_user(tim_isamb), - zebra_timing_get_sys(tim_isamb), + yaz_timing_get_real(tim_dict) + yaz_timing_get_real(tim_isamb), + yaz_timing_get_real(tim_dict), + yaz_timing_get_user(tim_dict), + yaz_timing_get_sys(tim_dict), + yaz_timing_get_real(tim_isamb), + yaz_timing_get_user(tim_isamb), + yaz_timing_get_sys(tim_isamb), number_of_int_splits, number_of_leaf_splits, no_docs, @@ -247,8 +248,8 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, b->no_entries = 0; b->terms = 0; - zebra_timing_destroy(&tim_isamb); - zebra_timing_destroy(&tim_dict); + yaz_timing_destroy(&tim_isamb); + yaz_timing_destroy(&tim_dict); } void index_block_check_flush(struct index_block *b, ISAMB isb, Dict dict, @@ -514,7 +515,7 @@ int main(int argc, char **argv) int dict_cache_size = 50; const char *fname = 0; FILE *inf = stdin; - zebra_timing_t tim = 0; + yaz_timing_t tim = 0; zint docid_seq = 1; const char *dict_info; const char *type = "iso2709"; @@ -599,7 +600,7 @@ int main(int argc, char **argv) if (reset) bf_reset(bfs); - tim = zebra_timing_create(); + tim = yaz_timing_create(); /* create isam handle */ isb_postings = isamb_open (bfs, "isamb", isam_cache_size ? 1 : 0, &method_postings, 0); @@ -635,14 +636,14 @@ int main(int argc, char **argv) fclose(inf); /* exit block system */ bfs_destroy(bfs); - zebra_timing_stop(tim); + yaz_timing_stop(tim); printf("# Total timings real=%8.6f user=%3.2f system=%3.2f\n", - zebra_timing_get_real(tim), - zebra_timing_get_user(tim), - zebra_timing_get_sys(tim)); + yaz_timing_get_real(tim), + yaz_timing_get_user(tim), + yaz_timing_get_sys(tim)); - zebra_timing_destroy(&tim); + yaz_timing_destroy(&tim); exit(0); return 0; diff --git a/isamb/benchisamb.c b/isamb/benchisamb.c index e9aaba7..396adc2 100644 --- a/isamb/benchisamb.c +++ b/isamb/benchisamb.c @@ -1,4 +1,4 @@ -/* $Id: benchisamb.c,v 1.4 2006-12-11 10:02:14 adam Exp $ +/* $Id: benchisamb.c,v 1.5 2007-01-05 10:45:12 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include @@ -134,9 +135,9 @@ void bench_insert(ISAMB isb, int number_of_trees, for (round = 0; round < number_of_rounds; round++) { - zebra_timing_t t = zebra_timing_create(); + yaz_timing_t t = yaz_timing_create(); - zebra_timing_start(t); + yaz_timing_start(t); for (i = 0; i - -#if HAVE_SYS_TIMES_H -#include -#endif -#if HAVE_SYS_TIME_H -#include -#endif - -#include -#include - -struct zebra_timing { - struct tms tms1, tms2; - struct timeval start_time, end_time; - double real_sec, user_sec, sys_sec; -}; - -zebra_timing_t zebra_timing_create(void) -{ - zebra_timing_t t = xmalloc(sizeof(*t)); - zebra_timing_start(t); - return t; -} - -void zebra_timing_start(zebra_timing_t t) -{ -#if HAVE_SYS_TIMES_H -#if HAVE_SYS_TIME_H - times(&t->tms1); - gettimeofday(&t->start_time, 0); -#endif -#endif - t->real_sec = -1.0; - t->user_sec = -1.0; - t->sys_sec = -1.0; -} - -void zebra_timing_stop(zebra_timing_t t) -{ - t->real_sec = 0.0; - t->user_sec = 0.0; - t->sys_sec = 0.0; -#if HAVE_SYS_TIMES_H -#if HAVE_SYS_TIME_H - gettimeofday(&t->end_time, 0); - times(&t->tms2); - - t->real_sec = ((t->end_time.tv_sec - t->start_time.tv_sec) * 1000000.0 + - t->end_time.tv_usec - t->start_time.tv_usec) / 1000000; - - t->user_sec = (double) (t->tms2.tms_utime - t->tms1.tms_utime)/100; - t->sys_sec = (double) (t->tms2.tms_stime - t->tms1.tms_stime)/100; -#endif -#endif -} - -double zebra_timing_get_real(zebra_timing_t t) -{ - return t->real_sec; -} - -double zebra_timing_get_user(zebra_timing_t t) -{ - return t->user_sec; -} - -double zebra_timing_get_sys(zebra_timing_t t) -{ - return t->sys_sec; -} - -void zebra_timing_destroy(zebra_timing_t *tp) -{ - if (*tp) - { - xfree(*tp); - *tp = 0; - } -} - -/* - * Local variables: - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - -- 1.7.10.4