stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r453314 - in /incubator/stdcxx/trunk/util: display.cpp exec.cpp target.h
Date Thu, 05 Oct 2006 18:51:40 GMT
Author: sebor
Date: Thu Oct  5 11:51:39 2006
New Revision: 453314

URL: http://svn.apache.org/viewvc?view=rev&rev=453314
Log:
2006-10-05  Andrew Black  <ablack@roguewave.com>

	* target.h: Update header comment.
	(target_status): Add wall field for wall clock timing.
	* exec.cpp [!_WIN32 && !_WIN64 && _XOPEN_UNIX] (sys/time.h): Included
	for gettimeofday.
	exec_file [!_WIN32 && !_WIN64 && _XOPEN_UNIX]: Set result->wall.
	exec_file [_WIN32 || _WIN64]: Ditto.
	* display.cpp (print_header_plain): Add column for wall clock time.
	(print_status_plain): Print result->wall, if set.

Modified:
    incubator/stdcxx/trunk/util/display.cpp
    incubator/stdcxx/trunk/util/exec.cpp
    incubator/stdcxx/trunk/util/target.h

Modified: incubator/stdcxx/trunk/util/display.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/display.cpp?view=diff&rev=453314&r1=453313&r2=453314
==============================================================================
--- incubator/stdcxx/trunk/util/display.cpp (original)
+++ incubator/stdcxx/trunk/util/display.cpp Thu Oct  5 11:51:39 2006
@@ -41,7 +41,7 @@
 static void print_header_plain ()
 {
     puts ("NAME                      STATUS ASSERTS FAILED PERCNT    USER     "
-          "SYS");
+          "SYS    WALL");
 }
 
 /**
@@ -81,18 +81,22 @@
         printf (" %7u %6u %5d%%", status->assert, status->failed, 
                 100 * (status->assert - status->failed) / status->assert);
     }
-    else if (valid_timing)
+    else if (valid_timing || status->wall)
         printf ("                      ");
 
     /* Print timings, if available */
     if (valid_timing)
-        printf (" %3ld.%03ld %3ld.%03ld\n", status->user->tv_sec,
+        printf (" %3ld.%03ld %3ld.%03ld", status->user->tv_sec,
                 status->user->tv_usec/1000, status->sys->tv_sec,
                 status->sys->tv_usec/1000);
-    else {
-        puts ("");
-    }
+    else if (status->wall)
+        printf ("                ");
 
+    if (status->wall)
+        printf (" %3ld.%03ld\n", status->wall->tv_sec,
+                status->wall->tv_usec/1000);
+    else
+        puts ("");
 }
 
 /**

Modified: incubator/stdcxx/trunk/util/exec.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/exec.cpp?view=diff&rev=453314&r1=453313&r2=453314
==============================================================================
--- incubator/stdcxx/trunk/util/exec.cpp (original)
+++ incubator/stdcxx/trunk/util/exec.cpp Thu Oct  5 11:51:39 2006
@@ -42,6 +42,7 @@
 #  include <sys/wait.h>
 #  ifdef _XOPEN_UNIX
 #    include <sys/resource.h> /* for setlimit(), RLIMIT_CORE, ... */
+#    include <sys/time.h> /* for gettimeofday */
 #  endif
 #else
 #  include <windows.h> /* for PROCESS_INFORMATION, ... */
@@ -871,9 +872,27 @@
               strerror (errno));
     }
     else {
+#ifdef _XOPEN_UNIX
+        struct timeval start;
+        static struct timeval delta;
+        gettimeofday(&start, 0);
+#endif /* _XOPEN_UNIX */
         /* parent */
         wait_for_child (child_pid, options->timeout, result);
         calculate_usage (result);
+#ifdef _XOPEN_UNIX
+        gettimeofday(&delta, 0);
+        delta.tv_sec -= start.tv_sec;
+        delta.tv_usec -= start.tv_usec;
+
+        /* Adjust seconds/microseconds */
+        if (delta.tv_usec < 0) {
+            --delta.tv_sec;
+            delta.tv_usec += 1000000;
+        }
+        /* Link the delta */
+        result->wall = &delta;
+#endif /* _XOPEN_UNIX */
     }
 }
 #else  /* _WIN{32,64} */
@@ -1080,6 +1099,8 @@
     SECURITY_ATTRIBUTES child_sa = /* SA for inheritable handle. */
           {sizeof (SECURITY_ATTRIBUTES), NULL, TRUE};
     DWORD real_timeout, wait_code;
+    FILETIME start, end, delta;
+    static rw_timeval convert;
 
     assert (0 != options);
     assert (0 != options->argv);
@@ -1126,6 +1147,10 @@
        and general-protection-fault message boxes */
     UINT old_mode = SetErrorMode (SEM_FAILCRITICALERRORS
                                 | SEM_NOGPFAULTERRORBOX);
+
+    /* Check the wall clock before creating the process */
+    GetSystemTimeAsFileTime(&start);
+
     /* Create the child process */
     if (0 == CreateProcess (options->argv [0], merged, 0, 0, 1, 
         CREATE_NEW_PROCESS_GROUP, 0, 0, &context, &child)) {
@@ -1170,6 +1195,25 @@
         result->status = ST_SYSTEM_ERROR;
         warn_last_error ("Waiting for child process");
     }
+
+    /* Calculate wall clock time elapsed while the process ran */
+    GetSystemTimeAsFileTime(&end);
+    delta.dwHighDateTime = end.dwHighDateTime - start.dwHighDateTime;
+    delta.dwLowDateTime = end.dwLowDateTime - start.dwLowDateTime;
+
+    /* Handle subtraction across the boundry */
+    if (end.dwLowDateTime < start.dwLowDateTime)
+        --delta.dwHighDateTime;
+
+    /* Convert from 128 bit number to seconds/microseconds */
+    convert.tv_usec = delta.dwLowDateTime % 10000000;
+    convert.tv_sec = (delta.dwLowDateTime - convert.tv_usec) / 10000000;
+    /* The low half of the date has a resolution of 100 nanoseconds, and
+       a magnitude of ~584 years.  Therefore, the upper half shouldn't 
+       matter. */
+
+    /* Link the delta */
+    result->wall = &convert;
 
     if (0 == GetExitCodeProcess (child.hProcess, (LPDWORD)&result->exit)) {
         warn_last_error ("Retrieving child process exit code");

Modified: incubator/stdcxx/trunk/util/target.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/target.h?view=diff&rev=453314&r1=453313&r2=453314
==============================================================================
--- incubator/stdcxx/trunk/util/target.h (original)
+++ incubator/stdcxx/trunk/util/target.h Thu Oct  5 11:51:39 2006
@@ -1,6 +1,6 @@
 /************************************************************************
  *
- * cmdopt.h - Interface declaration for the option parsing subsystem
+ * target.h - Struct definitions for target execution and results.
  *
  * $Id$
  *
@@ -140,6 +140,7 @@
     enum ProcessStatus status; /**< Textual process status. */
     const rw_timeval* user; /**< Elapsed user time spent in execution. */
     const rw_timeval* sys; /**< Elapsed system time spent in execution. */
+    const rw_timeval* wall; /**< Wall clock time spent in execution. */
     unsigned warn; /**< Number of (test) warnings. */
     unsigned assert; /**< Number of (test) assertions. */
     unsigned failed; /**< Number of failed (test) assertions. */



Mime
View raw message