From 8fe88d8a33b882c232964effbc2c2e53b90b7cbc Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Tue, 25 Oct 1994 14:36:04 +0000 Subject: [PATCH] Changed OS_process_clock so that it returns the process time (rather than the real time) under NT (or any variant of Win32 that supports GetProcessTimes). --- v7/src/microcode/ntenv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/v7/src/microcode/ntenv.c b/v7/src/microcode/ntenv.c index 85e1d11a4..a3ff82a6c 100644 --- a/v7/src/microcode/ntenv.c +++ b/v7/src/microcode/ntenv.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntenv.c,v 1.9 1993/09/03 17:54:57 gjr Exp $ +$Id: ntenv.c,v 1.10 1994/10/25 14:36:04 adams Exp $ Copyright (c) 1992-1993 Massachusetts Institute of Technology @@ -86,12 +86,22 @@ DEFUN (OS_encode_time ,(buffer), struct time_structure * buffer) return (t); } +#define FILETIME_TO_MSECS(ft) \ + (((4294967296.0 * (double) ft.dwHighDateTime) + ft.dwLowDateTime)*100e-6) + double DEFUN_VOID (OS_process_clock) { /* This must not signal an error in normal use. */ /* Return answer in milliseconds, was in 1/100th seconds */ - return ((((double) (clock ())) * 1000.0) / ((double) CLOCKS_PER_SEC)); + + FILETIME creation_time, exit_time, kernel_time, user_time; + if(GetProcessTimes(GetCurrentProcess(), + &creation_time, &exit_time, &kernel_time, &user_time)) { + return FILETIME_TO_MSECS(user_time) + FILETIME_TO_MSECS(kernel_time); + } else { + return ((((double) (clock ())) * 1000.0) / ((double) CLOCKS_PER_SEC)); + } } double -- 2.25.1