From e05cb2631696372c6bdabcabe22401efe9645ab7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 22 Dec 2006 12:14:25 +0000 Subject: [PATCH] Add timing for zebra_start/zebra_stop. --- index/index.h | 3 ++- index/zebraapi.c | 14 +++++++++++--- index/zebraidx.c | 40 +++------------------------------------- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/index/index.h b/index/index.h index 46ebddf..46c4c09 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.187 2006-12-18 23:40:07 adam Exp $ +/* $Id: index.h,v 1.188 2006-12-22 12:14:25 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -167,6 +167,7 @@ struct zebra_service { const char *path_root; RecTypeClass record_classes; NMEM nmem; + zebra_timing_t timing; }; diff --git a/index/zebraapi.c b/index/zebraapi.c index e13da6b..1b424e3 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.239 2006-12-19 16:57:38 adam Exp $ +/* $Id: zebraapi.c,v 1.240 2006-12-22 12:14:25 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -258,6 +258,7 @@ ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) } } + zh->timing = zebra_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); @@ -581,8 +582,6 @@ ZEBRA_RES zebra_stop(ZebraService zs) { if (!zs) return ZEBRA_OK; - yaz_log (log_level, "zebra_stop"); - while (zs->sessions) { zebra_close (zs->sessions); @@ -596,6 +595,15 @@ ZEBRA_RES zebra_stop(ZebraService zs) recTypeClass_destroy(zs->record_classes); nmem_destroy(zs->nmem); res_close (zs->global_res); + + zebra_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)); + + + zebra_timing_destroy(&zs->timing); xfree(zs); return ZEBRA_OK; } diff --git a/index/zebraidx.c b/index/zebraidx.c index 4fe0448..27a0a35 100644 --- a/index/zebraidx.c +++ b/index/zebraidx.c @@ -1,4 +1,4 @@ -/* $Id: zebraidx.c,v 1.2 2006-12-05 09:26:37 adam Exp $ +/* $Id: zebraidx.c,v 1.3 2006-12-22 12:14:25 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -30,13 +30,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #if HAVE_UNISTD_H #include #endif -#if HAVE_SYS_TIME_H -#include -#endif -#include -#if HAVE_SYS_TIMES_H -#include -#endif #include #include @@ -66,14 +59,7 @@ int main (int argc, char **argv) Res res = res_open(0, 0); Res default_res = res_open(0, 0); - int trans_started=0; -#if HAVE_SYS_TIMES_H - struct tms tms1, tms2; - double usec; -#endif -#if HAVE_SYS_TIME_H - struct timeval start_time, end_time; -#endif + int trans_started = 0; #ifndef WIN32 char nbuf[100]; #endif @@ -87,12 +73,6 @@ int main (int argc, char **argv) sprintf(nbuf, "%.40s(%ld)", *argv, (long) getpid()); yaz_log_init_prefix (nbuf); #endif -#if HAVE_SYS_TIMES_H - times(&tms1); -#endif -#if HAVE_SYS_TIME_H - gettimeofday(&start_time, 0); -#endif prog = *argv; if (argc < 2) { @@ -297,21 +277,7 @@ int main (int argc, char **argv) zebra_close (zh); zebra_stop (zs); -#if HAVE_SYS_TIMES_H -#if HAVE_SYS_TIME_H - if (trans_started) - { - gettimeofday(&end_time, 0); - usec = (end_time.tv_sec - start_time.tv_sec) * 1000000.0 + - end_time.tv_usec - start_time.tv_usec; - times(&tms2); - yaz_log (YLOG_LOG, "zebraidx times: %5.2f %5.2f %5.2f", - usec / 1000000, - (double) (tms2.tms_utime - tms1.tms_utime)/100, - (double) (tms2.tms_stime - tms1.tms_stime)/100); - } -#endif -#endif + res_close(res); res_close(default_res); nmem_exit(); -- 1.7.10.4