Changed OS_process_clock so that it returns the process time (rather
authorStephen Adams <edu/mit/csail/zurich/adams>
Tue, 25 Oct 1994 14:36:04 +0000 (14:36 +0000)
committerStephen Adams <edu/mit/csail/zurich/adams>
Tue, 25 Oct 1994 14:36:04 +0000 (14:36 +0000)
than the real time) under NT (or any variant of Win32 that supports
GetProcessTimes).

v7/src/microcode/ntenv.c

index 85e1d11a4c09a3bb515bce0073661bdcd875a294..a3ff82a6cd33c7d539f9f4f938d6b9aee35c637e 100644 (file)
@@ -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