From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15625 invoked by alias); 21 May 2012 20:22:06 -0000 Received: (qmail 15609 invoked by uid 22791); 21 May 2012 20:22:02 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ob0-f169.google.com (HELO mail-ob0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 May 2012 20:21:49 +0000 Received: by obbwd18 with SMTP id wd18so10928540obb.0 for ; Mon, 21 May 2012 13:21:48 -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=Wq3Bd6GF6w1glPkrbo0nKWlfkDw+woszHcHsR5T+/SE=; b=V0mz0OJ9zF2ffqAXaX/C0kAGKyml24C2odKVrgrV5gZXLjmnKVJx8stzEqoFPEh29w /eyLzzH2UPf9Df63Fi86LM+21Pz7vrqdq5423ei3Ya5R1voWJUIH2cD/LaMI3K0nQuG5 mQplvAjV6cCp9oKxoJTe1aT9oNzgjQrBO5aTfEl6skQn3xsYdLqClYk6dJemyYyjyZTm JDJLCWTcOm+MxuNeStm8l6Yfprguy5D6CRah3LMJmh66P/uPwm/9yOypMLnqW7WGFFYe pWY51H1zJfUPRQ+p3+kJ6a1qE1lsvqzWWbl1LBwZygBbv95P9OhQKf++0TbovQ2mHtH2 4cVg== Received: by 10.182.14.104 with SMTP id o8mr20537820obc.6.1337631708929; Mon, 21 May 2012 13:21:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.14.104 with SMTP id o8mr20537805obc.6.1337631708758; Mon, 21 May 2012 13:21:48 -0700 (PDT) Received: by 10.60.9.66 with HTTP; Mon, 21 May 2012 13:21:48 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 May 2012 20:22:00 -0000 Message-ID: Subject: [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: ALoCoQn2VaZgHuhsAfDeJS1DT41HG4Wu54aDwyv7XObirhSI37VDHQfslwQ5VCrYVe+yOgpFwk6JnhxlslU2Ps4518UiCEUtPsJI18879jRnVagJTz9LK5SVOE7t5L0lW48KXqwzm6RO2p+PZVUGo4GKiOdRrL2lpA== 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/msg00789.txt.bz2 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 --- a/gdb/utils.c 2012-05-11 12:21:33.000000000 -0700 +++ b/gdb/utils.c 2012-05-18 14:16:56.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. + 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); } @@ -1795,6 +1811,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 +1842,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"));