From owner-freebsd-current@FreeBSD.ORG Sat Apr 16 23:02:12 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE66B16A4CE for ; Sat, 16 Apr 2005 23:02:12 +0000 (GMT) Received: from pinus.cc.fer.hr (pinus.cc.fer.hr [161.53.73.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id 099EE43D5A for ; Sat, 16 Apr 2005 23:02:12 +0000 (GMT) (envelope-from ivoras@fer.hr) Received: from [161.53.72.113] (lara.cc.fer.hr [161.53.72.113]) by pinus.cc.fer.hr (8.12.2/8.12.2) with ESMTP id j3GN2qhE009479; Sun, 17 Apr 2005 01:02:53 +0200 (MEST) Message-ID: <4261996A.2030204@fer.hr> Date: Sun, 17 Apr 2005 01:02:02 +0200 From: Ivan Voras User-Agent: Mozilla Thunderbird 1.0 (X11/20041213) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Poul-Henning Kamp , current@freebsd.org References: <42616975.9060303@centtech.com> <3703.1113680811@critter.freebsd.dk> In-Reply-To: <3703.1113680811@critter.freebsd.dk> Content-Type: multipart/mixed; boundary="------------020703080201030807020200" Subject: Re: gstat shows > 100% busy X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Apr 2005 23:02:13 -0000 This is a multi-part message in MIME format. --------------020703080201030807020200 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Poul-Henning Kamp wrote: > The reason gstat shows >100% busy is that there are some outstanding > requests. (the 2 in the left hand column). > > I tried to make the statistics collection as cheap as possible, and > as a side effect some of the columns can be somewhat misleading. Could it be (for reasons of prettyfication) clipped to [0-100] range? Something like in the attached? --------------020703080201030807020200 Content-Type: text/plain; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" --- gstat_ori.c Sun Apr 17 00:45:32 2005 +++ gstat.c Sun Apr 17 00:59:44 2005 @@ -51,6 +51,7 @@ static int flag_I = 500000; static void usage(void); +static double clip_double(double x, double min, double max); int main(int argc, char **argv) @@ -209,7 +210,7 @@ else i = 1; attron(COLOR_PAIR(i)); - printw(" %6.1lf", (double)ld[7]); + printw(" %6.1lf", clip_double((double)ld[7], 0, 100)); attroff(COLOR_PAIR(i)); printw("|"); if (gid == NULL) { @@ -264,3 +265,18 @@ exit(1); /* NOTREACHED */ } + + +/* + * Clip a double value to [min..max] + */ +static double +clip_double(double x, double min, double max) +{ + if (x > max) + return max; + if (x < min) + return min; + return x; +} + --------------020703080201030807020200--