* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: timing.c,v 1.3 2007-01-05 12:40:05 adam Exp $
+ * $Id: timing.c,v 1.4 2007-01-05 14:05:24 adam Exp $
*/
/**
#endif
#ifdef WIN32
ULONGLONG start_time, end_time;
+ ULONGLONG start_time_sys, start_time_user;
+ ULONGLONG end_time_sys, end_time_user;
#endif
double real_sec, user_sec, sys_sec;
};
}
#ifdef WIN32
+static void get_process_time(ULONGLONG *lp_user, ULONGLONG *lp_sys)
+{
+ FILETIME create_t, exit_t, sys_t, user_t;
+ ULARGE_INTEGER li;
+
+ GetProcessTimes(GetCurrentProcess(), &create_t, &exit_t, &sys_t, &user_t);
+ li.LowPart = user_t.dwLowDateTime;
+ li.HighPart = user_t.dwHighDateTime;
+ *lp_user = li.QuadPart;
+
+ li.LowPart = sys_t.dwLowDateTime;
+ li.HighPart = sys_t.dwHighDateTime;
+ *lp_sys = li.QuadPart;
+}
static void get_date_as_largeinteger(ULONGLONG *lp)
{
FILETIME f;
t->real_sec = 0.0;
#endif
#ifdef WIN32
- get_date_as_largeinteger(&t->start_time);
t->real_sec = 0.0;
+ t->user_sec = 0.0;
+ t->sys_sec = 0.0;
+ get_date_as_largeinteger(&t->start_time);
+ get_process_time(&t->start_time_user, &t->start_time_sys);
#endif
}
#endif
#ifdef WIN32
get_date_as_largeinteger(&t->end_time);
- t->real_sec = (double) (t->end_time - t->start_time) / 10000000.0;
+ t->real_sec = (t->end_time - t->start_time) / 10000000.0;
+
+ get_process_time(&t->end_time_user, &t->end_time_sys);
+ t->user_sec = (t->end_time_user - t->start_time_user) / 10000000.0;
+ t->sys_sec = (t->end_time_sys - t->start_time_sys) / 10000000.0;
#endif
}