[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
${varname//orig/replacement} construct really slow
From: |
Steven Augart |
Subject: |
${varname//orig/replacement} construct really slow |
Date: |
Wed, 17 Mar 2004 18:55:00 -0500 (EST) |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
-D_GNU_SOURCE -O2 -g -pipe -march=i386 -mcpu=i686
uname output: Linux augart-tp23.watson.ibm.com 2.4.20-18.9 #1 Thu May 29
07:08:16 EDT 2003 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
The ${varname//orig/replacement} construct is really slow; it takes
741 milliseconds of CPU time (on a Pentium III, 1.1MHz) just
to perform a simple string transformation; in this case,
turning 32 colon characters into spaces, in a variable with a
608 character-long value.
(When I double the variable's length to
Repeat-By:
sh-2.05b$ time echo $foo
/bin:/usr/bin:/usr/local/bin:/home/augart/JikesRVM/Images/BaseBaseCopyMS+:/home/augart/JikesRVM/rvm/bin:/home/augart/JikesRVM/Configs:/opt/c4eb/bin:/opt/mts-client:/opt/IBMJava2-141/bin:/opt/Lotus/SameTime:/home/augart/.hosts:/home/augart/.bin:/home/augart/swa-startup/bash-lib:/usr/local/bin:/usr/local/sbin:/usr/local/mozilla:/sbin:/usr/sbin:/usr/bin:/bin:/usr/games:/usr/X11R6/bin:/usr/lib/java/bin:/home/augart/swa-startup:/home/augart/swa-startup/Oursite:/usr/local/etc:/home/augart/swa-startup/Oursite:/usr/local/etc:/home/augart/swa-startup/Oursite:/usr/local/etc:/opt/globus/bin:/opt/globus/sbin:/opt/c4eb/bin:/opt/IBMJava2-141/bin:/opt/c4eb/bin:/opt/IBMJava2-141/bin:/opt/c4eb/bin:/opt/IBMJava2-141/bin
real 0m0.001s
user 0m0.000s
sys 0m0.000s
sh-2.05b$ time echo ${foo//:/ } > /dev/null
real 0m0.741s
user 0m0.740s
sys 0m0.000s
sh-2.05b$
Here are some other timings that may be helpful in tracking down the
source of the problem. (It goes up to 5872 milliseconds if I just
double the length of the variable):
sh-2.05b$ foo=$foo$foo
sh-2.05b$ time echo ${foo//:/ } > /dev/null
real 0m5.872s
user 0m5.820s
sys 0m0.010s
sh-2.05b$
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ${varname//orig/replacement} construct really slow,
Steven Augart <=