On Fri, 21 Jul 2023 at 22:37, tito <[email protected]> wrote:
>
> On Fri, 21 Jul 2023 21:39:57 +0200
> "Roberto A. Foglietta" <[email protected]> wrote:
>
> > To the maintainers and everyone else whom can be interested,
> >
[...]
>
> Hi,
> seems to me that the current strings busybox implementation is faster.
>
[...]
@Tito, first of all thanks for the test.
The 'strings' applet into busybox is good enough for me and moreover,
it is not about performance. The busybox installed into the system can
theoretically be replaced but adding the only thing I am missing is
easier. For my personal needs, this thread could be ended here.
Just for sake of completeness, I took some tests too. There are
several ways to use 'strings' and they belong to a matrix of 2x3 cases
in:{file, stdin} X out:{file, stdout, /dev/null}.
We can agree about the stdin case that the time of completion greatly
depends on the way in which stdin feeds the command and among many
ways the 'cat' is probably the most typical. Another aspect that can
change the performances is about pre-compiled VS locally-compiled
binaries. Therefore, the standard pre-compiled busybox has been
introduced into the tests which finally create a 4 dimensions matrix
like this {gnu strings, system busybox, compiled busybox, compiled
strings} x :{file, stdin} X out:{file, stdout, /dev/null}.
Finally, we need a test function with parameters and a basic but
reasonably accurate average calculation. Using this function over the
above 4D matrix, I am feeling confident in saying that:
1. there is no difference between pre-compiled and locally-compiled busybox
2. the busybox strings is as fast as GNU strings
3. the code I sent is on average 2x faster
4. the code I sent worst case is just 23% slower of the best of the
others 3 cases
5. the code I sent best case is above 4x faster than the best of the
others 3 cases
Here below all the information to replicate the test on different
systems and architectures.
cat /proc/cpuinfo | grep "model name" | tail -n1
model name : Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
GNOME Terminal
Version 3.44.0 for GNOME 42
Using VTE version 0.68.0 +BIDI +GNUTLS +ICU +SYSTEMD
stats() {
rm -f t.time
local cmd=${1:-/usr/bin/busybox strings /usr/bin/busybox} n=${2:-100}
for i in $(seq 1 $n); do eval time $cmd; done 2>t.time
{
echo
echo "$cmd"
sed -ne "s,real\t,min: ,p" t.time | sort -n | head -n1
let avg=$(sed -ne "s,real\t0m0.[0]*\([0-9]*\)s,\\1,p" t.time | tr '\n' '+')0
printf "avg: 0m0.%03ds\n" $(( (50+$avg)/100 ))
sed -ne "s,real\t,max: ,p" t.time | sort -n | tail -n1
} >&2
}
=============
/usr/bin/busybox | head -n1
BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) multi-call binary.
rm -f 1.txt; cmd="/usr/bin/busybox strings /usr/bin/busybox";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
/usr/bin/busybox strings /usr/bin/busybox
min: 0m0.067s
avg: 0m0.090s
max: 0m0.134s
/usr/bin/busybox strings /usr/bin/busybox
min: 0m0.013s
avg: 0m0.013s
max: 0m0.016s
/usr/bin/busybox strings /usr/bin/busybox
min: 0m0.013s
avg: 0m0.014s
max: 0m0.018s
rm -f 1.txt; cmd="cat /usr/bin/busybox | /usr/bin/busybox strings";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
cat /usr/bin/busybox | /usr/bin/busybox strings
min: 0m0.072s
avg: 0m0.095s
max: 0m0.141s
cat /usr/bin/busybox | /usr/bin/busybox strings
min: 0m0.021s
avg: 0m0.022s
max: 0m0.026s
cat /usr/bin/busybox | /usr/bin/busybox strings
min: 0m0.021s
avg: 0m0.022s
max: 0m0.025s
=============
./busybox | head -n1
BusyBox v1.37.0.git (2023-07-21 15:06:26 CEST) multi-call binary.
gcc --version | head -n1
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
rm -f 1.txt; cmd="./busybox strings /usr/bin/busybox";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.tx
./busybox strings /usr/bin/busybox
min: 0m0.064s
avg: 0m0.089s
max: 0m0.123s
./busybox strings /usr/bin/busybox
min: 0m0.014s
avg: 0m0.014s
max: 0m0.016s
./busybox strings /usr/bin/busybox
min: 0m0.014s
avg: 0m0.014s
max: 0m0.016s
rm -f 1.txt; cmd="cat /usr/bin/busybox | ./busybox strings";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
cat /usr/bin/busybox | ./busybox strings
min: 0m0.075s
avg: 0m0.098s
max: 0m0.148s
cat /usr/bin/busybox | ./busybox strings
min: 0m0.022s
avg: 0m0.023s
max: 0m0.033s
cat /usr/bin/busybox | ./busybox strings
min: 0m0.023s
avg: 0m0.023s
max: 0m0.027s
=============
gcc -Wall -O3 strings.c -o strings && strip strings
gcc --version | head -n1
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
rm -f 1.txt; cmd="../redfishos/recovery/strings /usr/bin/busybox";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
../redfishos/recovery/strings /usr/bin/busybox
min: 0m0.015s
avg: 0m0.040s
max: 0m0.079s
../redfishos/recovery/strings /usr/bin/busybox
min: 0m0.009s
avg: 0m0.009s
max: 0m0.010s
../redfishos/recovery/strings /usr/bin/busybox
min: 0m0.009s
avg: 0m0.010s
max: 0m0.021s
rm -f 1.txt; cmd="cat /usr/bin/busybox | ../redfishos/recovery/strings strings";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
cat /usr/bin/busybox | ../redfishos/recovery/strings
min: 0m0.041s
avg: 0m0.050s
max: 0m0.082s
cat /usr/bin/busybox | ../redfishos/recovery/strings
min: 0m0.017s
avg: 0m0.017s
max: 0m0.019s
cat /usr/bin/busybox | ../redfishos/recovery/strings
min: 0m0.017s
avg: 0m0.017s
max: 0m0.024s
=============
strings --version | head -n1
GNU strings (GNU Binutils for Ubuntu) 2.38
rm -f 1.txt; cmd="strings /usr/bin/busybox";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
strings /usr/bin/busybox
min: 0m0.073s
avg: 0m0.097s
max: 0m0.136s
strings /usr/bin/busybox
min: 0m0.020s
avg: 0m0.021s
max: 0m0.024s
strings /usr/bin/busybox
min: 0m0.021s
avg: 0m0.021s
max: 0m0.026s
rm -f 1.txt; cmd="cat /usr/bin/busybox | strings";
stats "$cmd "; stats "$cmd" >/dev/null; stats "$cmd" >1.txt
cat /usr/bin/busybox | strings
min: 0m0.077s
avg: 0m0.103s
max: 0m0.140s
cat /usr/bin/busybox | strings
min: 0m0.029s
avg: 0m0.029s
max: 0m0.039s
cat /usr/bin/busybox | strings
min: 0m0.029s
avg: 0m0.029s
max: 0m0.037s
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox