Subject: Re: field widths in ps(1).
To: Simon Burge <email@example.com>
From: David Brownlee <firstname.lastname@example.org>
Date: 05/31/2000 10:21:55
On Wed, 31 May 2000, Simon Burge wrote:
> Something I've had on the back burner for a while (and completely
> forgotten about) was some mods to ps(1) so that each field would be only
> as wide as it needs to be, so that not only more can fit on the screen
> but wide columns when they happen line up to.
> The main drawback for this is that it effectively runs through the
> process list twice - once to calculate the maximum field widths and
> another to display the results. On my 166MHz PPro, this equates to 0.04
> seconds to show 73 processes with the old ps(1) and 0.06 seconds with
> the new.
> Given that ps would be roughtly 50% slower, would these changes be a
> good thing or a bad things to add to the source tree?
I'd like to see the numbers for a machine with 500 or so httpd
process, and one being hammering into the ground before I'd
Maybe have an option to turn the new behaviour on/off, and default
to on if stdout is a tty?
> I just knocked up a "q"uick mode that doesn't do any column line-ups:
> wincen:src/bin/psNEW 299> ./obj.i386/ps qaux | head
> USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
> root 0 0.0 6.1 0 7964 ?? DLs 11:43AM 0:00.02 (swapper)
> simonb 1373 0.0 0.1 272 136 p0 R+ 4:20PM 0:00.00 ./obj.i386/ps aux
> simonb 1226 0.0 0.9 672 1108 p0 T 3:57PM 0:04.84 vi print.c ps.c ps.h
> simonb 213 0.0 0.7 916 864 p0 Ds 12:01PM 0:01.18 -tcsh
> This could be used in scripts where only the field number is important,
> but then that would make any such scripts NetBSD specific because of the
> extra option - probably not good...
We already have such goodies as a subsecond sleep(1) for non
standard scripts. Unless the "q"uick mode has any speed gain over
the original dumb formatting I'd be inclined to stick the the
orignal and the 'new' formatted.
-- www.netbsd.org: No hype required --