* utils.c: #include "timeval-utils.h".
authorDoug Evans <dje@google.com>
Fri, 4 Nov 2011 16:45:13 +0000 (16:45 +0000)
committerDoug Evans <dje@google.com>
Fri, 4 Nov 2011 16:45:13 +0000 (16:45 +0000)
(cmd_stats): Rename start_time to start_cpu_time.
New member start_wall_time.
(report_command_stats): Report wall time.
(make_command_stats_cleanup): Record start wall time.

doc/
* gdb.texinfo (Maintenance Commands): Update docs of "maint time".

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/utils.c

index e3e782683c010cffef1632de32caf7b2c7050fd6..f527f202aa903d774b98e6648b4042f59172d6a9 100644 (file)
@@ -1,3 +1,11 @@
+2011-11-04  Doug Evans  <dje@google.com>
+
+       * utils.c: #include "timeval-utils.h".
+       (cmd_stats): Rename start_time to start_cpu_time.
+       New member start_wall_time.
+       (report_command_stats): Report wall time.
+       (make_command_stats_cleanup): Record start wall time.
+
 2011-11-04  Tom Tromey  <tromey@redhat.com>
 
        * cp-namespace.c (cp_lookup_symbol_imports): Reindent.
index 9beca6f53888f0e169e68f11089fd99283d909f3..2a23823da0f00224d554e2243e0b0bd755792022 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-04  Doug Evans  <dje@google.com>
+
+       * gdb.texinfo (Maintenance Commands): Update docs of "maint time".
+
 2011-11-03  Tom Tromey  <tromey@redhat.com>
 
        * gdb.texinfo (Stopping): Add menu entry.
index 93450c689c772c34769f567607b3dac601473061..520360f96f262d6edfa4bcfd02cf99e21995a48b 100644 (file)
@@ -32991,13 +32991,16 @@ switch (@pxref{Mode Options}).
 @kindex maint time
 @cindex time of command execution
 @item maint time
-Control whether to display the execution time for each command.  If
-set to a nonzero value, @value{GDBN} will display how much time it
+Control whether to display the execution time of @value{GDBN} for each command.
+If set to a nonzero value, @value{GDBN} will display how much time it
 took to execute each command, following the command's own output.
-The time is not printed for the commands that run the target, since
-there's no mechanism currently to compute how much time was spend
-by @value{GDBN} and how much time was spend by the program been debugged.
-it's not possibly currently 
+Both CPU time and wallclock time are printed.
+Printing both is useful when trying to determine whether the cost is
+CPU or, e.g., disk/network, latency.
+Note that the CPU time printed is for @value{GDBN} only, it does not include
+the execution time of the inferior because there's no mechanism currently
+to compute how much time was spent by @value{GDBN} and how much time was
+spent by the program been debugged.
 This can also be requested by invoking @value{GDBN} with the
 @option{--statistics} command-line switch (@pxref{Mode Options}).
 
index 5c03e71e3521db7fda5a638206cf4d8e6de974a3..008baac20c74838c0d7e01a9c2ee3561d5c32853 100644 (file)
@@ -45,6 +45,7 @@
 #endif
 
 #include <signal.h>
+#include "timeval-utils.h"
 #include "gdbcmd.h"
 #include "serial.h"
 #include "bfd.h"
@@ -691,7 +692,8 @@ static int display_space;
 struct cmd_stats 
 {
   int msg_type;
-  long start_time;
+  long start_cpu_time;
+  struct timeval start_wall_time;
   long start_space;
 };
 
@@ -723,12 +725,18 @@ report_command_stats (void *arg)
 
   if (display_time)
     {
-      long cmd_time = get_run_time () - start_stats->start_time;
+      long cmd_time = get_run_time () - start_stats->start_cpu_time;
+      struct timeval now_wall_time, delta_wall_time;
+
+      gettimeofday (&now_wall_time, NULL);
+      timeval_sub (&delta_wall_time,
+                  &now_wall_time, &start_stats->start_wall_time);
 
       printf_unfiltered (msg_type == 0
-                        ? _("Startup time: %ld.%06ld\n")
-                        : _("Command execution time: %ld.%06ld\n"),
-                        cmd_time / 1000000, cmd_time % 1000000);
+                        ? _("Startup time: %ld.%06ld (cpu), %ld.%06ld (wall)\n")
+                        : _("Command execution time: %ld.%06ld (cpu), %ld.%06ld (wall)\n"),
+                        cmd_time / 1000000, cmd_time % 1000000,
+                        delta_wall_time.tv_sec, delta_wall_time.tv_usec);
     }
 
   if (display_space)
@@ -764,7 +772,8 @@ make_command_stats_cleanup (int msg_type)
 #endif
 
   new_stat->msg_type = msg_type;
-  new_stat->start_time = get_run_time ();
+  new_stat->start_cpu_time = get_run_time ();
+  gettimeofday (&new_stat->start_wall_time, NULL);
 
   return make_cleanup_dtor (report_command_stats, new_stat, xfree);
 }
This page took 0.071747 seconds and 4 git commands to generate.