2 * Copyright (C) 1995-2007, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: timing.c,v 1.1 2007-01-03 13:46:18 adam Exp $
10 * \brief Timing Utilities
20 #include <sys/times.h>
27 #include <yaz/xmalloc.h>
28 #include <yaz/timing.h>
32 struct tms tms1, tms2;
35 struct timeval start_time, end_time;
37 double real_sec, user_sec, sys_sec;
40 yaz_timing_t yaz_timing_create(void)
42 yaz_timing_t t = xmalloc(sizeof(*t));
47 void yaz_timing_start(yaz_timing_t t)
53 gettimeofday(&t->start_time, 0);
60 void yaz_timing_stop(yaz_timing_t t)
68 t->user_sec = (double) (t->tms2.tms_utime - t->tms1.tms_utime)/100;
69 t->sys_sec = (double) (t->tms2.tms_stime - t->tms1.tms_stime)/100;
72 gettimeofday(&t->end_time, 0);
73 t->real_sec = ((t->end_time.tv_sec - t->start_time.tv_sec) * 1000000.0 +
74 t->end_time.tv_usec - t->start_time.tv_usec) / 1000000;
79 double yaz_timing_get_real(yaz_timing_t t)
84 double yaz_timing_get_user(yaz_timing_t t)
89 double yaz_timing_get_sys(yaz_timing_t t)
94 void yaz_timing_destroy(yaz_timing_t *tp)
106 * indent-tabs-mode: nil
108 * vim: shiftwidth=4 tabstop=8 expandtab