From patchwork Wed Dec 9 06:38:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Graunke X-Patchwork-Id: 65893 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB96cZd6006062 for ; Wed, 9 Dec 2009 06:38:35 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6DBDB9F30E; Tue, 8 Dec 2009 22:38:33 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from homiemail-a2.g.dreamhost.com (caiajhbdcagg.dreamhost.com [208.97.132.66]) by gabe.freedesktop.org (Postfix) with ESMTP id D76AE9F30B for ; Tue, 8 Dec 2009 22:38:29 -0800 (PST) Received: from novari.localnet (pool-71-117-215-4.ptldor.fios.verizon.net [71.117.215.4]) by homiemail-a2.g.dreamhost.com (Postfix) with ESMTP id BF825D26B6 for ; Tue, 8 Dec 2009 22:38:27 -0800 (PST) From: Kenneth Graunke To: intel-gfx@lists.freedesktop.org Date: Tue, 8 Dec 2009 22:38:18 -0800 User-Agent: KMail/1.12.4 (Linux/2.6.32-rc6-kms; KDE/4.3.4; x86_64; ; ) MIME-Version: 1.0 Message-Id: <200912082238.18387.kenneth@whitecape.org> Subject: [Intel-gfx] [PATCH] Limit printing to terminal height in intel_gpu_top. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index d314eda..9ef3ae4 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "intel_gpu_tools.h" #include "instdone.h" @@ -257,6 +258,13 @@ int main(int argc, char **argv) qsort(top_bits_sorted, num_instdone_bits, sizeof(struct top_bit *), top_bits_sort); + /* Limit the number of lines printed to the terminal height so the + * most important info (at the top) will stay on screen. */ + unsigned short int max_lines = -1; + struct winsize ws; + if (ioctl(0, TIOCGWINSZ, &ws) != -1) + max_lines = ws.ws_row - 6; /* exclude header lines */ + printf("%s", clear_screen); print_clock_info(); @@ -275,11 +283,13 @@ int main(int argc, char **argv) if (top_bits_sorted[i]->count < 1) break; - percent = top_bits_sorted[i]->count / SAMPLES_TO_PERCENT_RATIO; - len = printf("%30s: %3d%%: ", - top_bits_sorted[i]->bit->name, - percent); - print_percentage_bar (percent, len); + if (i < max_lines) { + percent = top_bits_sorted[i]->count / SAMPLES_TO_PERCENT_RATIO; + len = printf("%30s: %3d%%: ", + top_bits_sorted[i]->bit->name, + percent); + print_percentage_bar (percent, len); + } top_bits_sorted[i]->count = 0;