From: Nick Roberts <nickrob@snap.net.nz>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] MI: new timing command
Date: Sun, 28 Jan 2007 05:31:00 -0000 [thread overview]
Message-ID: <17852.13579.802713.886821@kahikatea.snap.net.nz> (raw)
In-Reply-To: <uejpfaipa.fsf@gnu.org>
> > Well it was explained to me that get_run_time basically returns wallclock
> > time when getrusage isn't defined.
>
> Not necessarily. Take a look at getruntime.c: it can use `times' when
> that is available. `times' returns the sum of user and system times,
> not the wallclock time.
I don't recollect this point being made earlier but anyway I've tried to make
the necessary changes below.
--
Nick http://www.inet.net.nz/~nickrob
Other changes as before. In particular mi-main.c is a pseudo diff as other
previous changes aren't shown.
*** mi-parse.h 28 Jan 2007 10:54:38 +1300 1.6
--- mi-parse.h 28 Jan 2007 18:18:46 +1300
***************
*** 24,29 ****
--- 24,36 ----
/* MI parser */
+ /* Timestamps for current command and last asynchronous command. */
+ struct mi_timestamp {
+ struct timeval wallclock;
+ struct timeval utime;
+ struct timeval stime;
+ };
+
enum mi_command_type
{
MI_COMMAND, CLI_COMMAND
*************** struct mi_parse
*** 35,40 ****
--- 42,48 ----
char *command;
char *token;
const struct mi_cmd *cmd;
+ struct mi_timestamp *cmd_start;
char *args;
char **argv;
int argc;
*** mi-main.c 23 Jan 2007 20:21:56 +1300 1.91
--- mi-main.c 28 Jan 2007 18:15:17 +1300
*************** _initialize_mi_main (void)
*** 1457,1459 ****
--- 1517,1565 ----
DEPRECATED_REGISTER_GDBARCH_SWAP (old_regs);
deprecated_register_gdbarch_swap (NULL, 0, mi_setup_architecture_data);
}
+
+ static void
+ timestamp (struct mi_timestamp *tv)
+ {
+ long usec;
+ gettimeofday (&tv->wallclock, NULL);
+ #ifdef HAVE_GETRUSAGE
+ getrusage (RUSAGE_SELF, &rusage);
+ tv->utime.tv_sec = rusage.ru_utime.tv_sec;
+ tv->utime.tv_usec = rusage.ru_utime.tv_usec;
+ tv->stime.tv_sec = rusage.ru_stime.tv_sec;
+ tv->stime.tv_usec = rusage.ru_stime.tv_usec;
+ #else
+ usec = get_run_time ();
+ tv->utime.tv_sec = usec/1000000;
+ tv->utime.tv_usec = usec - 1000000*tv->utime.tv_sec;
+ tv->stime.tv_sec = 0;
+ tv->stime.tv_usec = 0;
+ #endif
+ }
+
+ static void
+ print_diff_now (struct mi_timestamp *start)
+ {
+ struct mi_timestamp now;
+ timestamp (&now);
+ print_diff (start, &now);
+ }
+
+ static long
+ timeval_diff (struct timeval start, struct timeval end)
+ {
+ return ((end.tv_sec - start.tv_sec) * 1000000)
+ + (end.tv_usec - start.tv_usec);
+ }
+
+ static void
+ print_diff (struct mi_timestamp *start, struct mi_timestamp *end)
+ {
+ fprintf_unfiltered
+ (raw_stdout,
+ ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}",
+ timeval_diff (start->wallclock, end->wallclock) / 1000000.0,
+ timeval_diff (start->utime, end->utime) / 1000000.0,
+ timeval_diff (start->stime, end->stime) / 1000000.0);
+ }
next prev parent reply other threads:[~2007-01-28 5:31 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-30 8:52 Nick Roberts
2006-12-30 12:09 ` Vladimir Prus
2006-12-30 16:10 ` Eli Zaretskii
2006-12-31 3:26 ` Nick Roberts
2006-12-31 4:26 ` Eli Zaretskii
2006-12-31 6:55 ` Nick Roberts
2006-12-31 15:10 ` Daniel Jacobowitz
2007-01-01 4:11 ` Nick Roberts
2007-01-03 18:01 ` Daniel Jacobowitz
2007-01-03 21:50 ` Nick Roberts
2007-01-03 22:59 ` Daniel Jacobowitz
2007-01-04 2:50 ` Nick Roberts
2006-12-31 15:33 ` Vladimir Prus
2006-12-30 16:09 ` Eli Zaretskii
2006-12-30 22:10 ` Nick Roberts
2006-12-31 4:22 ` Eli Zaretskii
2006-12-31 4:25 ` Daniel Jacobowitz
2006-12-31 5:18 ` Nick Roberts
2006-12-31 5:49 ` Daniel Jacobowitz
2006-12-31 7:47 ` Nick Roberts
2006-12-31 15:15 ` Daniel Jacobowitz
2006-12-31 15:24 ` Mark Kettenis
2006-12-31 15:39 ` Vladimir Prus
2006-12-31 16:09 ` Mark Kettenis
2006-12-31 16:21 ` Vladimir Prus
2006-12-31 19:29 ` Daniel Jacobowitz
2006-12-31 22:08 ` Eli Zaretskii
2007-01-01 4:24 ` Nick Roberts
2007-01-01 6:06 ` Eli Zaretskii
2007-01-01 4:07 ` Nick Roberts
2007-01-01 5:58 ` Eli Zaretskii
2007-01-01 22:07 ` Nick Roberts
2007-01-02 4:20 ` Eli Zaretskii
2007-01-16 5:57 ` Nick Roberts
2007-01-16 22:17 ` Eli Zaretskii
2007-01-16 22:30 ` Nick Roberts
2007-01-16 23:01 ` Eli Zaretskii
2007-01-20 17:27 ` Eli Zaretskii
2007-01-20 20:58 ` Nick Roberts
2007-01-27 14:53 ` Eli Zaretskii
2007-01-27 15:10 ` Eli Zaretskii
2007-01-27 22:12 ` Nick Roberts
2007-01-27 22:19 ` Nick Roberts
2007-01-27 22:08 ` Nick Roberts
2007-01-28 4:17 ` Eli Zaretskii
2007-01-28 5:31 ` Nick Roberts [this message]
2007-02-02 13:33 ` Eli Zaretskii
2007-02-02 23:28 ` Nick Roberts
2007-02-03 11:10 ` Eli Zaretskii
2007-01-01 9:18 ` Nick Roberts
2007-01-01 16:21 ` Daniel Jacobowitz
2006-12-31 15:34 ` Vladimir Prus
2006-12-31 11:58 ` Mark Kettenis
2006-12-31 7:50 ` Nick Roberts
2006-12-31 18:33 ` Vladimir Prus
2007-01-01 4:18 ` Nick Roberts
2006-12-31 22:10 ` Eli Zaretskii
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=17852.13579.802713.886821@kahikatea.snap.net.nz \
--to=nickrob@snap.net.nz \
--cc=eliz@gnu.org \
--cc=gdb-patches@sources.redhat.com \
/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