From 99d73aaa969a333373e5e2cc01a6aac16e378c3c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 5 Jan 2007 14:05:24 +0000 Subject: [PATCH] Windows port of yaz_timing_t --- src/timing.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/timing.c b/src/timing.c index 0276d07..0486eb8 100644 --- a/src/timing.c +++ b/src/timing.c @@ -2,7 +2,7 @@ * 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 $ */ /** @@ -39,6 +39,8 @@ struct yaz_timing { #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; }; @@ -51,6 +53,20 @@ yaz_timing_t yaz_timing_create(void) } #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; @@ -79,8 +95,11 @@ void yaz_timing_start(yaz_timing_t t) 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 } @@ -100,7 +119,11 @@ void yaz_timing_stop(yaz_timing_t t) #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 } -- 1.7.10.4