* 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 $
+ * $Id: timing.c,v 1.3 2007-01-05 12:40:05 adam Exp $
*/
/**
#include <config.h>
#endif
+#ifdef WIN32
+#include <windows.h>
+#endif
#include <stdlib.h>
#if HAVE_SYS_TIMES_H
#if HAVE_SYS_TIME_H
struct timeval start_time, end_time;
#endif
+#ifdef WIN32
+ ULONGLONG start_time, end_time;
+#endif
double real_sec, user_sec, sys_sec;
};
return t;
}
+#ifdef WIN32
+static void get_date_as_largeinteger(ULONGLONG *lp)
+{
+ FILETIME f;
+ ULARGE_INTEGER li;
+ GetSystemTimeAsFileTime(&f);
+ li.LowPart = f.dwLowDateTime;
+ li.HighPart = f.dwHighDateTime;
+
+ *lp = li.QuadPart;
+}
+#endif
+
void yaz_timing_start(yaz_timing_t t)
{
#if HAVE_SYS_TIMES_H
times(&t->tms1);
+ t->user_sec = 0.0;
+ t->sys_sec = 0.0;
+#else
+ t->user_sec = -1.0;
+ t->sys_sec = -1.0;
#endif
+ t->real_sec = -1.0;
#if HAVE_SYS_TIME_H
gettimeofday(&t->start_time, 0);
+ t->real_sec = 0.0;
+#endif
+#ifdef WIN32
+ get_date_as_largeinteger(&t->start_time);
+ t->real_sec = 0.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->end_time.tv_usec - t->start_time.tv_usec) / 1000000;
#endif
+#ifdef WIN32
+ get_date_as_largeinteger(&t->end_time);
+ t->real_sec = (double) (t->end_time - t->start_time) / 10000000.0;
+#endif
}
double yaz_timing_get_real(yaz_timing_t t)