[PATCH] new applet: nmeter

Denis Vlasenko vda.linux at googlemail.com
Wed Jul 5 12:58:53 PDT 2006


On Wednesday 05 July 2006 21:43, Rich Felker wrote:
> On Wed, Jul 05, 2006 at 06:31:56PM +0200, Denis Vlasenko wrote:
> > Hi,
> > 
> > The patch adds the following applet:
> > 
> > # ./busybox nmeter 
> > BusyBox v1.2.0 (2006.07.04-21:29+0000) multi-call binary 
> >  
> > Usage: nmeter format_string 
> >  
> > Nmeter monitors your system in real time. 
> >  
> > Format specifiers: 
> > %Nc or %[cN]    monitor CPU. N - bar size, default 10 
> >                 (displays: S:system U:user N:niced D:iowait I:irq i:softirq) 
> > %[niface]       monitor network interface 'iface' 
> > %m              monitor allocated memory 
> > %[mf]           monitor free memory 
> > %[mt]           monitor total memory 
> > %s              monitor allocated swap 
> > %f              monitor number of used file descriptors 
> > %Ni             monitor total/specific IRQ rate 
> > %x              monitor context switch rate 
> > %p              monitor forks 
> > %[pn]           monitor # of processes 
> > %b              monitor block io 
> > %Nt             show time (with N decimal points) 
> > %Nd             milliseconds between updates (default=1000) 
> > %r              print <cr> instead of <lf> at EOL 
> > 
> > Size of the applet (make objsizes):
> > 
> > text+data text+rodata    rwdata       bss filename 
> >      5090        4954       136      4104 miscutils/nmeter.o 
> > 
> > Run tested.
> 
> looks rather large relative to what it does.

Biggest functions are:

+00000040 t simple_itoa
+00000042 t readfile_z
+00000046 t init_delay
+00000055 t init_cpu
+00000057 t init_time
+0000005a t init_if
+0000005f t collect_fd
+00000066 t collect_ctx
+00000066 t collect_fork
+00000067 t collect_int
+00000074 t collect_swp
+0000007d t vrdval
+000000ba t collect_time - see below why not strftime
+000000c5 t collect_if
+00000158 t scale - used to cleverly display positive numbers,
                    even huge ones, in 4 characters
+00000182 t collect_mem
+0000021c t collect_blk - large because has both 2.4 and 2.6 functions
+00000292 T nmeter_main
+000002b7 t collect_cpu

> What about removing some 
> of the cruft from the source at least, like the non-USE_LOCALTIME
> cases?

non-USE_LOCALE removal is ok with me, but irrelevant to the binary size.

> also imo the code would be smaller using strftime for printing 
> times instead of inlining the hh:mm:ss string generation, etc. since
> strftime is already used in bb anyway.

Do you want strftime to parse "%H:%M:%S" format string _on each call_?
Will strftime round to nearest last displayed digit in fractional second?
Can it do fractional seconds at all, let alone with user specified
resolution (number of digits after the dot)?

> just some ideas, dunno if the maintainers will agree or not.

Thanks, I did find some things which can be made smaller while I was
looking at the source!

Waiting for maintainers' words...
--
vda


More information about the busybox mailing list