gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] trevor_1_12.3


From: Trevor Morris
Subject: [gnugo-devel] trevor_1_12.3
Date: Fri, 26 Oct 2001 09:22:30 -0400

http://www.public32.com/games/go/trevor_1_12.3
 - corrects gg_cputime to return cpu time under Unix.
 - adds warning if no cpu time function available.


Index: utils/gg_utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/utils/gg_utils.c,v
retrieving revision 1.14
diff -u -r1.14 gg_utils.c
--- utils/gg_utils.c    2001/10/22 15:18:50     1.14
+++ utils/gg_utils.c    2001/10/26 13:17:10
@@ -272,7 +272,9 @@
 {
 #if HAVE_SYS_TIMES_H && HAVE_TIMES
     struct tms t;
-    return times(&t) / ((double) CLOCKS_PER_SEC);
+    times(&t);
+    return (t.tms_utime + t.tms_stime + t.tms_cutime + t.tms_cstime)
+            / ((double) CLOCKS_PER_SEC);
 #elif defined(WIN32)
     FILETIME creationTime, exitTime, kernelTime, userTime;
     ULARGE_INTEGER uKernelTime,uUserTime,uElapsedTime;
@@ -287,6 +289,11 @@
     /* convert from multiples of 100nanosecs to seconds: */
     return (signed __int64)(uElapsedTime.QuadPart) * 1.e-7;
 #else
+    static int warned = 0;
+    if (!warned) {
+      fprintf(stderr, "CPU timing unavailable - returning wall time.");
+      warned = 1;
+    }
     /* return wall clock seconds */
     return gg_gettimeofday();
 #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]