Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15249 > unrolled thread
| Started by | Alkis Georgopoulos <alkisg@gmail.com> |
|---|---|
| First post | 2019-07-26 12:55 +0300 |
| Last post | 2019-07-26 12:55 +0300 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Optimize bash string handling? Alkis Georgopoulos <alkisg@gmail.com> - 2019-07-26 12:55 +0300
| From | Alkis Georgopoulos <alkisg@gmail.com> |
|---|---|
| Date | 2019-07-26 12:55 +0300 |
| Subject | Optimize bash string handling? |
| Message-ID | <mailman.2297.1564149161.2688.bug-bash@gnu.org> |
While handling some big strings, I noticed that bash is a lot slower
than other shells like dash, posh and busybox ash.
I came up with the following little benchmark and results.
While the specific benchmark isn't important, maybe some developer
would like to use it to pinpoint and optimize some internal bash
function that is a lot slower than in other shells?
# Avoid UTF-8 complications
export LANG=C
# Run the following COMMANDs with `time bash -c`
# or `time busybox ash -c`
# The time columns are in seconds, on an i5-4440 CPU
ASH BASH COMMAND
0.1 0.1 printf "%100000000s" "." >/dev/null
0.7 1.1 x=$(printf "%100000000s" ".")
0.8 2.4 x=$(printf "%100000000s" "."); echo ${#x}
0.9 3.7 x=$(printf "%100000000s" "."); echo ${#x}; echo ${#x}
At this point I think it's safe to assume that just calculating the
100MB string length in bash needs 1.3 secs, while in ash 0.1 secs.
Similar differences may be observed in simple assignments like y=$i$x.
If anyone replies, please CC me as I'm not in the list.
Thanks,
Alkis Georgopoulos
Back to top | Article view | gnu.bash.bug
csiph-web