+Added timings utility (yaz/timing.h)
+
--- 2.1.44 2007/01/03
Added yaz_marc_write_xml which creates MARCXML/MarcXchange record as
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])
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])
-## $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 \
\
--- /dev/null
+/*
+ * 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/yconfig.h>
+
+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
+ */
+
* (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.
#include <yaz/yconfig.h>
-#define YAZ_VERSION "2.1.44"
-#define YAZ_VERSIONL 0x02012C
+#define YAZ_VERSION "2.1.45"
+#define YAZ_VERSIONL 0x02012D
#define YAZ_DATE 1
## 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
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
--- /dev/null
+/*
+ * 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 <config.h>
+#endif
+
+#include <stdlib.h>
+
+#if HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <time.h>
+
+#include <yaz/xmalloc.h>
+#include <yaz/timing.h>
+
+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
+ */
+
# 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
$(OBJDIR)\cqlutil.obj \
$(OBJDIR)\cqlstrer.obj \
$(OBJDIR)\xcqlutil.obj \
- $(OBJDIR)\elementset.obj
+ $(OBJDIR)\elementset.obj \
+ $(OBJDIR)\timing.obj
Z3950_OBJS= \
$(OBJDIR)\z-date.obj\