]> git.proxmox.com Git - mirror_iproute2.git/commit
ss: Buffer raw fields first, then render them as a table
authorStefano Brivio <sbrivio@redhat.com>
Tue, 12 Dec 2017 00:46:32 +0000 (01:46 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 12 Dec 2017 20:11:37 +0000 (12:11 -0800)
commit691bd854bf4abcd4ef7ddeeae56450ec81d32872
tree14ce102c7f991e7e96738edf5d4b0466a4d7a00c
parent59f46b7b5be86a81ee4525a689735688d9080a7b
ss: Buffer raw fields first, then render them as a table

This allows us to measure the maximum field length for each
column before printing fields and will permit us to apply
optimal field spacing and distribution. Structure of the output
buffer with chunked allocation is described in comments.

Output is still unchanged, original spacing is used.

Running over one million sockets with -tul options by simply
modifying main() to loop 50,000 times over the *_show()
functions, buffering the whole output and rendering it at the
end, with 10 UDP sockets, 10 TCP sockets, while throwing
output away, doesn't show significant changes in execution time
on my laptop with an Intel i7-6600U CPU:

- before this patch:
$ time ./ss -tul > /dev/null
real 0m29.899s
user 0m2.017s
sys 0m27.801s

- after this patch:
$ time ./ss -tul > /dev/null
real 0m29.827s
user 0m1.942s
sys 0m27.812s

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
misc/ss.c