Name: Anonymous 2008-10-20 0:19
???
#!/bin/sh
testperl() {
perl -le "'$1' =~ /$2/ or print 'wrong result'"
}
testawk() {
echo $1 | awk "/$2/ {m = 1} END {if (! m) print \"wrong result\"}"
}
testpython() {
python -c "if not __import__('re').search(r'$2', '$1'): print 'wrong result'"
}
repeat() {
r=$1
e="$2"
while [ $r -gt 0 ]; do
r=`expr $r - 1`
echo -n "$e"
done
echo
}
# adapt these as you like, but 25 is sufficently enough to show how bad perl sucks at this
for n in 1 5 10 20 25; do
i=`repeat $n a`
r=`repeat $n a\?`$i
echo n = $n
for body in awk perl python
do
echo "$body":
time test$body $i $r
done
echo
done