* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: timing.c,v 1.2 2007-01-05 11:44:49 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
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;
-#else
- t->real_sec = -1.0;
+#endif
+#ifdef WIN32
+ get_date_as_largeinteger(&t->start_time);
+ t->real_sec = 0.0;
#endif
}
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)
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tst_timing.c,v 1.1 2007-01-05 11:45:11 adam Exp $
+ * $Id: tst_timing.c,v 1.2 2007-01-05 12:40:05 adam Exp $
*/
#include <stdlib.h>
#include <yaz/timing.h>
#include <yaz/test.h>
#include <yaz/log.h>
+#ifdef WIN32
+#include <windows.h>
+#endif
static void tst(void)
{
if (!t)
return;
+#ifdef WIN32
+ Sleep(100);
+#endif
for (i = 0; i<100000; i++)
;