ash vs. dash performance
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Sat Apr 12 01:55:40 PDT 2008
Please consider the example code in the attachment. That script is
supposed to show that a simple 'tr'-like shell function is faster than a
real forked 'tr'.
My empirical numbers show a factor 5 better performance for the shell_tr
function (ash and dash). Just for amusement I even tested the same thing
using bash, and that gave a factor 2 and took twice the time dash took to
do the same thing. The only thing I modified in the script between the
runs is the shebang line. I tested this with:
BusyBox v1.10.0 (2008-04-11 21:41:20 CEST) multi-call binary
as:
BusyBox v1.11.0.svn (2008-04-09 23:08:44 CEST) multi-call binary
has a problem with ${parameter#word}.
Numbers (the pc is a pentium4 3.4GHz):
,---- [ performance factor: 2.13 ]
| # ./substring_process.sh 100000
| 23:41:20 ../substring_process.sh: using tr
| in: ABC.123.xyz
| out: ABC_123_xyz
| 23:44:49 ../substring_process.sh: elapsed 209
|
| 23:44:49 ../substring_process.sh: using tr-free
| in: ABC.123.xyz
| out: ABC_123_xyz
| 23:46:27 ../substring_process.sh: elapsed 98
`----
Ash does this much better:
,---- [ performance factor: 4.68 ]
| # ./substring_process.sh 100000
| 23:29:00 ../substring_process.sh: using tr
| in: ABC.123.xyz
| out: ABC_123_xyz
| 23:31:16 ../substring_process.sh: elapsed 136
|
| 23:31:16 ../substring_process.sh: using tr-free
| in: ABC.123.xyz
| out: ABC_123_xyz
| 23:31:45 ../substring_process.sh: elapsed 29
`----
Still, dash is best:
,---- [ performance factor: 5.31 ]
| ./substring_process.sh 100000
| 23:38:12 ../substring_process.sh: using tr
| in: ABC.123.xyz
| out: ABC_123_xyz
| 23:40:09 ../substring_process.sh: elapsed 117
|
| 23:40:09 ../substring_process.sh: using tr-free
| in: ABC.123.xyz
| out: ABC_123_xyz
| 23:40:31 ../substring_process.sh: elapsed 22
`----
It would be very interesting to hear if it is possible to squeeze some
better performance out of ash. Don't get me wrong, ash's performance is
very good (compared to bash) but dash's is better. And, especially for
embedded systems, that makes a difference.
Cheers,
--
Cristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: substring_process.sh
Type: application/x-sh
Size: 1588 bytes
Desc:
Url : http://busybox.net/lists/busybox/attachments/20080412/37ab10b1/attachment.sh
More information about the busybox
mailing list