From: Adam Dickmeiss Date: Wed, 3 Jan 2007 13:46:17 +0000 (+0000) Subject: Added timings utility. Bump version to 2.1.45. X-Git-Tag: YAZ.2.1.46~29 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=75c07fe53a0cf8bb2c138cb6d87cde84d3b8b6a6;p=yaz-moved-to-github.git Added timings utility. Bump version to 2.1.45. --- diff --git a/NEWS b/NEWS index 49b5559..8a6e915 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +Added timings utility (yaz/timing.h) + --- 2.1.44 2007/01/03 Added yaz_marc_write_xml which creates MARCXML/MarcXchange record as diff --git a/configure.ac b/configure.ac index fb1cdfd..ebc640c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl YAZ Toolkit, Index Data 1995-2007 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.53 2007-01-03 08:42:13 adam Exp $ +dnl $Id: configure.ac,v 1.54 2007-01-03 13:46:17 adam Exp $ AC_PREREQ(2.59) -AC_INIT([yaz],[2.1.44],[yaz-help@indexdata.dk]) +AC_INIT([yaz],[2.1.45],[yaz-help@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([1.8]) @@ -23,7 +23,7 @@ YAZ_DOC dnl dnl dnl ------ Headers -AC_CHECK_HEADERS(dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/un.h sys/wait.h unistd.h netinet/if_ether.h netinet/in_systm.h) +AC_CHECK_HEADERS(dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h unistd.h netinet/if_ether.h netinet/in_systm.h) AC_HEADER_STDC if test "$ac_cv_header_stdc" = "no"; then AC_MSG_WARN([Your system doesn not seem to support ANSI C]) diff --git a/include/yaz/Makefile.am b/include/yaz/Makefile.am index 7f818ee..7b37175 100644 --- a/include/yaz/Makefile.am +++ b/include/yaz/Makefile.am @@ -1,11 +1,11 @@ -## $Id: Makefile.am,v 1.36 2006-12-13 11:25:17 adam Exp $ +## $Id: Makefile.am,v 1.37 2007-01-03 13:46:17 adam Exp $ pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \ diagbib1.h diagsrw.h diagsru_update.h sortspec.h log.h logrpn.h marcdisp.h \ nmem.h nmem_xml.h odr.h \ oid.h options.h otherinfo.h pquery.h prt-ext.h querytowrbuf.h \ readconf.h record_conv.h retrieval.h statserv.h \ - tcpip.h test.h unix.h tpath.h wrbuf.h xmalloc.h \ + tcpip.h test.h timing.h unix.h tpath.h wrbuf.h xmalloc.h \ yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \ xmlquery.h libxml2_error.h xmltypes.h \ \ diff --git a/include/yaz/timing.h b/include/yaz/timing.h new file mode 100644 index 0000000..6058701 --- /dev/null +++ b/include/yaz/timing.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1995-2007, Index Data + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Index Data nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* $Id: timing.h,v 1.1 2007-01-03 13:46:17 adam Exp $ */ + +/** + * \file timing.h + * \brief Timing Utilities + */ + +#ifndef YAZ_TIMING_H +#define YAZ_TIMING_H + +#include + +YAZ_BEGIN_CDECL + +typedef struct yaz_timing *yaz_timing_t; + +YAZ_EXPORT +yaz_timing_t yaz_timing_create(void); +YAZ_EXPORT +void yaz_timing_start(yaz_timing_t t); +YAZ_EXPORT +void yaz_timing_stop(yaz_timing_t t); +YAZ_EXPORT +double yaz_timing_get_real(yaz_timing_t t); +YAZ_EXPORT +double yaz_timing_get_user(yaz_timing_t t); +YAZ_EXPORT +double yaz_timing_get_sys(yaz_timing_t t); +YAZ_EXPORT +void yaz_timing_destroy(yaz_timing_t *tp); + +YAZ_END_CDECL + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/yaz/yaz-version.h b/include/yaz/yaz-version.h index 8f00df4..e5e1f52 100644 --- a/include/yaz/yaz-version.h +++ b/include/yaz/yaz-version.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: yaz-version.h,v 1.108 2007-01-03 08:42:14 adam Exp $ */ +/* $Id: yaz-version.h,v 1.109 2007-01-03 13:46:17 adam Exp $ */ /** * \file yaz-version.h * \brief Defines YAZ version. @@ -33,8 +33,8 @@ #include -#define YAZ_VERSION "2.1.44" -#define YAZ_VERSIONL 0x02012C +#define YAZ_VERSION "2.1.45" +#define YAZ_VERSIONL 0x02012D #define YAZ_DATE 1 diff --git a/src/Makefile.am b/src/Makefile.am index d163182..430c797 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ ## This file is part of the YAZ toolkit. ## Copyright (C) 1995-2007, Index Data, All rights reserved. -## $Id: Makefile.am,v 1.47 2007-01-03 08:42:15 adam Exp $ +## $Id: Makefile.am,v 1.48 2007-01-03 13:46:18 adam Exp $ YAZ_VERSION_INFO=2:1:0 @@ -77,7 +77,7 @@ libyaz_la_SOURCES=version.c options.c log.c \ cql.y cqlstdio.c cqltransform.c cqlutil.c xcqlutil.c cqlstring.c \ cqlstrer.c querytowrbuf.c \ eventl.c seshigh.c statserv.c requestq.c tcpdchk.c \ - eventl.h service.c service.h session.h test.c \ + eventl.h service.c service.h session.h test.c timing.c \ xmlquery.c \ mime.c mime.h \ record_conv.c retrieval.c elementset.c diff --git a/src/timing.c b/src/timing.c new file mode 100644 index 0000000..6957bc9 --- /dev/null +++ b/src/timing.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 1995-2007, Index Data ApS + * See the file LICENSE for details. + * + * $Id: timing.c,v 1.1 2007-01-03 13:46:18 adam Exp $ + */ + +/** + * \file timing.c + * \brief Timing Utilities + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +#if HAVE_SYS_TIMES_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif +#include + +#include +#include + +struct yaz_timing { +#if HAVE_SYS_TIMES_H + struct tms tms1, tms2; +#endif +#if HAVE_SYS_TIME_H + struct timeval start_time, end_time; +#endif + double real_sec, user_sec, sys_sec; +}; + +yaz_timing_t yaz_timing_create(void) +{ + yaz_timing_t t = xmalloc(sizeof(*t)); + yaz_timing_start(t); + return t; +} + +void yaz_timing_start(yaz_timing_t t) +{ +#if HAVE_SYS_TIMES_H + times(&t->tms1); +#endif +#if HAVE_SYS_TIME_H + gettimeofday(&t->start_time, 0); +#endif + t->real_sec = -1.0; + t->user_sec = -1.0; + t->sys_sec = -1.0; +} + +void yaz_timing_stop(yaz_timing_t t) +{ + t->real_sec = 0.0; + t->user_sec = 0.0; + t->sys_sec = 0.0; +#if HAVE_SYS_TIMES_H + times(&t->tms2); + + 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 +#if HAVE_SYS_TIME_H + gettimeofday(&t->end_time, 0); + 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; + +#endif +} + +double yaz_timing_get_real(yaz_timing_t t) +{ + return t->real_sec; +} + +double yaz_timing_get_user(yaz_timing_t t) +{ + return t->user_sec; +} + +double yaz_timing_get_sys(yaz_timing_t t) +{ + return t->sys_sec; +} + +void yaz_timing_destroy(yaz_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 + */ + diff --git a/win/makefile b/win/makefile index 1ac9eef..878c88f 100644 --- a/win/makefile +++ b/win/makefile @@ -1,6 +1,6 @@ # Copyright (C) 1995-2007, Index Data ApS # All rights reserved. -# $Id: makefile,v 1.123 2007-01-03 08:42:17 adam Exp $ +# $Id: makefile,v 1.124 2007-01-03 13:46:18 adam Exp $ # # Programmed by # Heikki Levanto & Adam Dickmeiss @@ -418,7 +418,8 @@ MISC_OBJS= \ $(OBJDIR)\cqlutil.obj \ $(OBJDIR)\cqlstrer.obj \ $(OBJDIR)\xcqlutil.obj \ - $(OBJDIR)\elementset.obj + $(OBJDIR)\elementset.obj \ + $(OBJDIR)\timing.obj Z3950_OBJS= \ $(OBJDIR)\z-date.obj\