By now the Useless Use of cat Award is very well known, and there's also a mention of a Useless Use of echo (not relevant for this question). I'm wondering if there should be a Useless Use of echo in Bash Award: Piping seems to be much slower than heredocs and herestrings according to some highly unscientific measurements:Heredocs:for reps in 1 2 3do    time for i in {1..1000}    do        cat <<'END'test stringEND    done > /dev/nulldonereal    0m1.786suser    0m0.212ssys     0m0.332sreal    0m1.817suser    0m0.232ssys     0m0.332sreal    0m1.846suser    0m0.256ssys     0m0.320sHerestringsfor reps in 1 2 3do    time for i in {1..1000}    do        cat <<< 'test string'    done > /dev/nulldonereal    0m1.932suser    0m0.280ssys     0m0.288sreal    0m1.956suser    0m0.248ssys     0m0.348sreal    0m1.968suser    0m0.268ssys     0m0.324sRedirectionfor reps in 1 2 3do    time for i in {1..1000}    do        echo 'test string' | cat    done > /dev/nulldonereal    0m3.562suser    0m0.416ssys     0m0.548sreal    0m3.924suser    0m0.384ssys     0m0.604sreal    0m3.343suser    0m0.400ssys     0m0.552sIn general, heredocs and herestrings are about the same speed (this is just one data set from several tests) while redirection is consistently more than 50% slower. Am I misunderstanding something, or could this be used as a general rule for commands reading standard input in Bash?
echo vs <<
bash;io redirection;pipe;performance
First, let's concentrate on performance. I ran benchmarks for a slightly different program on an otherwise mostly idle x86_64 processor running Debian squeeze.herestring.bash, using a herestring to pass a line of input:#! /bin/bashi=0while [ $i -lt $1 ]; do  tr a-z A-Z <<<'hello world'  i=$((i+1))done >/dev/nullheredoc.bash, using a heredoc to pass a line of input:#! /bin/bashi=0while [ $i -lt $1 ]; do  tr a-z A-Z <<'EOF'hello worldEOF  i=$((i+1))done >/dev/nullecho.bash, using echo and a pipe to pass a line of input:#! /bin/bashi=0while [ $i -lt $1 ]; do  echo 'hello world' | tr a-z A-Z  i=$((i+1))done >/dev/nullFor comparison, I also timed the scripts under ATT ksh93 and under dash (except for herestring.bash, because dash doesn't have herestrings).Here are median-of-three times:$ time bash ./herestring.bash 10000./herestring.bash 10000  0.32s user 0.79s system 15% cpu 7.088 total$ time ksh ./herestring.bash 10000ksh ./herestring.bash 10000  0.54s user 0.41s system 17% cpu 5.277 total$ time bash ./heredoc.bash 10000./heredoc.bash 10000  0.35s user 0.75s system 17% cpu 6.406 total$ time ksh ./heredoc.bash 10000  ksh ./heredoc.sh 10000  0.54s user 0.44s system 19% cpu 4.925 total$ time sh ./heredoc.bash 10000  ./heredoc.sh 10000  0.08s user 0.58s system 12% cpu 5.313 total$ time bash ./echo.bash 10000./echo.bash 10000  0.36s user 1.40s system 20% cpu 8.641 total$ time ksh ./echo.bash 10000ksh ./echo.sh 10000  0.47s user 1.51s system 28% cpu 6.918 total$ time sh ./echo.sh 10000./echo.sh 10000  0.07s user 1.00s system 16% cpu 6.463 totalConclusions:A heredoc is faster than a herestring.echo and a pipe is noticeably, but not dramatically faster. (Keep in mind that this is a toy program: in a real program, most of the processing time would be in whatever the tr call stands for here.)If you want speed, ditch bash and call dash or even better ksh instead. Bash's features don't make up for its relative slowness, but ksh has both features and speed.Beyond performance, there's also clarity and portability. <<< is a ksh93/bash/zsh extension which is less well-known than echo  | or <<. It doesn't work in ksh88/pdksh or in POSIX sh.The only place where <<< is arguably significantly clearer is inside a heredoc:foo=$(tr a-z A-Z <<<'hello world')vsfoo=$(tr a-z A-Z <<'EOF'hello worldEOF)(Most shells can't cope with closing the parenthesis at the end of the line containing <<EOF.)