[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bad performance for substring replacement by pattern
From: |
Yi Yan |
Subject: |
Bad performance for substring replacement by pattern |
Date: |
Mon, 12 Jul 2010 20:27:15 +0000 |
Hi,
I used the following Bash script to test substring replacement operator.
It is performance get worse very quickly with the increasing of the string
length.
I test the script with Bash(4.1) on Debian Linux machine.
See the execution time difference by increasing the $NUM in the script:
========================================
#! /usr/local/bin/bash
declare z="start"
declare NUM=1000
#----------------------------------
# create a long string with ';'
#----------------------------------
for ((i=0; i<$NUM; i++)); do
z="$z;string$i"
done
#------------------------------
# delete everything except ';'
#------------------------------
date +%s
x="${z//[^;]}"
echo $x
date +%s
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
- Bad performance for substring replacement by pattern,
Yi Yan <=