Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [RFA, doc RFA] Include wallclock time in "maint time" output.
Date: Tue, 20 Sep 2011 05:32:00 -0000	[thread overview]
Message-ID: <20110920041137.A67D02461A0@ruffy.mtv.corp.google.com> (raw)

Hi.

It is often useful to see the wallclock time of commands.
This patch adds wallclock time to the output from "maint time 1".

This patch depends on a patch for libiberty, pending approval.
http://gcc.gnu.org/ml/gcc-patches/2011-09/msg01118.html
I'll revise this as appropriate, but can I get an RFA on the
addition of wallclock time to the output?

[Other bits of gdb can make use of timeval-utils.h,
that's another patch.]

2011-09-19  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.

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

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.261
diff -u -p -r1.261 utils.c
--- utils.c	9 Sep 2011 19:41:14 -0000	1.261
+++ utils.c	20 Sep 2011 03:42:22 -0000
@@ -44,6 +44,7 @@
 #endif
 
 #include <signal.h>
+#include "timeval-utils.h"
 #include "gdbcmd.h"
 #include "serial.h"
 #include "bfd.h"
@@ -641,7 +642,8 @@ static int display_space;
 struct cmd_stats 
 {
   int msg_type;
-  long start_time;
+  struct timeval start_wall_time;
+  long start_cpu_time;
   long start_space;
 };
 
@@ -673,12 +675,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)
@@ -714,7 +722,8 @@ make_command_stats_cleanup (int msg_type
 #endif
 
   new_stat->msg_type = msg_type;
-  new_stat->start_time = get_run_time ();
+  gettimeofday (&new_stat->start_wall_time, NULL);
+  new_stat->start_cpu_time = get_run_time ();
 
   return make_cleanup_dtor (report_command_stats, new_stat, xfree);
 }
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.862
diff -u -p -r1.862 gdb.texinfo
--- doc/gdb.texinfo	16 Sep 2011 09:07:01 -0000	1.862
+++ doc/gdb.texinfo	20 Sep 2011 04:02:07 -0000
@@ -32240,13 +32240,12 @@ 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.
+Note that the cpu time printed is for @value{GDBN} only, it does not include
+the execution time of the inferior.
 This can also be requested by invoking @value{GDBN} with the
 @option{--statistics} command-line switch (@pxref{Mode Options}).
 


             reply	other threads:[~2011-09-20  4:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20  5:32 Doug Evans [this message]
2011-09-20  5:42 ` Eli Zaretskii
2011-09-20  7:09   ` Doug Evans
2011-09-20  7:19     ` Eli Zaretskii
2011-09-20 15:20       ` Eli Zaretskii
2011-11-03 23:18       ` Doug Evans
2011-11-04  9:01         ` Eli Zaretskii
2011-11-04 16:46           ` Doug Evans
2011-10-03 19:11 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110920041137.A67D02461A0@ruffy.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox