From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5949 invoked by alias); 22 May 2012 20:50:01 -0000 Received: (qmail 5940 invoked by uid 22791); 22 May 2012 20:50:00 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_RV,TW_TR,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yx0-f169.google.com (HELO mail-yx0-f169.google.com) (209.85.213.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 May 2012 20:49:44 +0000 Received: by yenm7 with SMTP id m7so7114352yen.0 for ; Tue, 22 May 2012 13:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:x-system-of-record :x-gm-message-state; bh=ipa8YSFaj/ORA6S7ycAP/mEF42ZXfTwXonWvDtJJrkg=; b=agZ5JRRzhatOGOP4mjxy4QgeR4+iqMpzNmj+zu3smWlSOp9e5uOMCYHbS7JmAM+juh o9WSp0ByRkM3y3A4cIlM5+B7fWStKdFqfeTxVlM4DcPdAH1BgiK5BXFXEfZFCo1TT6+1 0EuOATTEok1i8GTs89Lm6lMvpQ4L+VIp2aABEfS3dJkJTWroKDiBXF+s/ftWuDSlQJZ1 H4CPwjZLac0/ECI3ejJtnIeGzankRejtNOdUqqt5zhfFAlo5PsfJl4JRsrtJg7dSDw/g SZ+B8GCGgNBl8SvLLYniEFGHwe2jng1SGPVdVjjTGLVIr1FttLrScMGwGowhAgz2yg1b bRiQ== Received: by 10.50.154.167 with SMTP id vp7mr7809607igb.49.1337719783239; Tue, 22 May 2012 13:49:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.154.167 with SMTP id vp7mr7809599igb.49.1337719783101; Tue, 22 May 2012 13:49:43 -0700 (PDT) Received: by 10.50.46.231 with HTTP; Tue, 22 May 2012 13:49:43 -0700 (PDT) In-Reply-To: References: Date: Tue, 22 May 2012 20:50:00 -0000 Message-ID: Subject: Re: [PATCH] Remove time waiting for user from walltime in stats From: Aaron Gamble To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQnF6jtegqZymO08gJVbzcIEwgXv0LrQEC8Ynzj6ii7nTnGyjmDlycA8rkd9E+hYjXSlh20SiuJpThTLOSgSwvERqUPjwPwqx1YMMCSbYMz5RKBD1AxWzUwbU8r/D3xpt4PCIo2P6dHG3MQNaM+JPYV8XTsSCw== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-05/txt/msg00850.txt.bz2 re: http://sourceware.org/ml/gdb-patches/2012-05/msg00790.html Here is an updated version of the patch to also remove the time spend at y/n decision/question prompts. * utils.c (prompt_for_continue_wait_time): New static global. (make_command_stats_cleanup): Initialize it. (report_command_stats): Subtract time waiting for user. (prompt_for_continue): Track time waiting for user. (defaulted_query): Track time waiting for user. --- a/gdb/utils.c 2012-05-20 14:22:01.000000000 -0700 +++ b/gdb/utils.c 2012-05-22 12:00:08.000000000 -0700 @@ -104,6 +104,14 @@ static void set_screen_size (void); static void set_width (void); +/* Time spent in prompt_for_continue in the currently executing command + waiting for user to respond. + Initialized in make_command_stats_cleanup. + Modified in prompt_for_continue and defaulted_query. + Used in report_command_stats. */ + +static struct timeval prompt_for_continue_wait_time; + /* A flag indicating whether to timestamp debugging messages. */ static int debug_timestamp =3D 0; @@ -535,6 +543,10 @@ timeval_sub (&delta_wall_time, &now_wall_time, &start_stats->start_wall_time); + /* Subtract time spend in prompt_for_continue from walltime. */ + timeval_sub (&delta_wall_time, + &delta_wall_time, &prompt_for_continue_wait_time); + printf_unfiltered (msg_type =3D=3D 0 ? _("Startup time: %ld.%06ld (cpu), %ld.%06ld (wall)\n") : _("Command execution time: %ld.%06ld (cpu), %ld.%06ld (wall)\n"), @@ -568,6 +580,7 @@ struct cleanup * make_command_stats_cleanup (int msg_type) { + static const struct timeval zero_timeval =3D { 0 }; struct cmd_stats *new_stat =3D XMALLOC (struct cmd_stats); #ifdef HAVE_SBRK @@ -578,6 +591,9 @@ new_stat->msg_type =3D msg_type; new_stat->start_cpu_time =3D get_run_time (); gettimeofday (&new_stat->start_wall_time, NULL); + + /* Initalize timer to keep track of how long we waited for the user. */ + prompt_for_continue_wait_time =3D zero_timeval; return make_cleanup_dtor (report_command_stats, new_stat, xfree); } @@ -1188,6 +1204,9 @@ int def_value; char def_answer, not_def_answer; char *y_string, *n_string, *question; + /* Used to add duration we waited for user to respond to + prompt_for_continue_wait_time. */ + struct timeval prompt_started, prompt_ended, prompt_delta; /* Set up according to which answer is the default. */ if (defchar =3D=3D '\0') @@ -1244,6 +1263,9 @@ /* Format the question outside of the loop, to avoid reusing args. */ question =3D xstrvprintf (ctlstr, args); + + /* Used for calculating time spend waiting for user. */ + gettimeofday (&prompt_started, NULL); while (1) { @@ -1321,6 +1343,12 @@ printf_filtered (_("Please answer %s or %s.\n"), y_string, n_string); } + + /* Add time spend in this routine to prompt_for_continue_wait_time. */ + gettimeofday (&prompt_ended, NULL); + timeval_sub (&prompt_delta, &prompt_ended, &prompt_started); + timeval_add (&prompt_for_continue_wait_time, + &prompt_for_continue_wait_time, &prompt_delta); xfree (question); if (annotation_level > 1) @@ -1795,6 +1823,11 @@ { char *ignore; char cont_prompt[120]; + /* Used to add duration we waited for user to respond to + prompt_for_continue_wait_time. */ + struct timeval prompt_started, prompt_ended, prompt_delta; + + gettimeofday (&prompt_started, NULL); if (annotation_level > 1) printf_unfiltered (("\n\032\032pre-prompt-for-continue\n")); @@ -1821,6 +1854,12 @@ whereas control-C to gdb_readline will cause the user to get dumped out to DOS. */ ignore =3D gdb_readline_wrapper (cont_prompt); + + /* Add time spend in this routine to prompt_for_continue_wait_time. */ + gettimeofday (&prompt_ended, NULL); + timeval_sub (&prompt_delta, &prompt_ended, &prompt_started); + timeval_add (&prompt_for_continue_wait_time, + &prompt_for_continue_wait_time, &prompt_delta); if (annotation_level > 1) printf_unfiltered (("\n\032\032post-prompt-for-continue\n")); On Mon, May 21, 2012 at 2:01 PM, Doug Evans wrote: > On Mon, May 21, 2012 at 1:43 PM, Aaron Gamble wrote: >> Oops. Corrected ChangeLog entry: >> >> =A0 =A0 =A0* utils.c (prompt_for_continue_wait_time): New static global. >> =A0 =A0 =A0 (make_command_stats_cleanup): Initialize it. >> =A0 =A0 =A0 (report_command_stats): Subtract time waiting for user. >> =A0 =A0 =A0 (prompt_for_continue): Track time waiting for user. >> >> >> -Aaron >> >> On Mon, May 21, 2012 at 1:21 PM, Aaron Gamble wrote: >>> Hi, >>> >>> Here is a patch to remove the time a gdb is waiting for a user to >>> respond to paging from gdb's internal statistics. Currently if a user >>> is reading paged output and waits 10 seconds to read/respond, those 10 >>> seconds are added to the walltime for the command issued. >>> >>> Time spent waiting for the user is stored in a global static variable >>> in utils.c and is subtracted from the wall time when the stats are >>> printed. >>> >>> 2012-05-21 =A0Aaron Gamble =A0 >>> >>> =A0 =A0 * gdb/utils.c: Added global static variable to track time spend >>> waiting for user in paging > > The patch is ok with me. > > Give it a few days to see if anyone wants to comment.