Skip to content

Instantly share code, notes, and snippets.

@Stantheman
Created May 15, 2012 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stantheman/2702322 to your computer and use it in GitHub Desktop.
Save Stantheman/2702322 to your computer and use it in GitHub Desktop.
comparing here strings and pipes
#!/bin/bash
for i in {1..1000}; do
sed 's/lo//' <<< "hello world\n"
done
➜ ~ time ./pipes.sh &>/dev/null
./pipes.sh &> /dev/null 0.46s user 5.36s system 121% cpu 4.806 total
➜ ~ time ./herestring.sh &>/dev/null
./herestring.sh &> /dev/null 0.39s user 3.54s system 99% cpu 3.960 total
➜ ~ time ./pipes.sh &>/dev/null
./pipes.sh &> /dev/null 0.43s user 5.31s system 121% cpu 4.724 total
➜ ~ time ./herestring.sh &>/dev/null
./herestring.sh &> /dev/null 0.38s user 3.60s system 99% cpu 4.001 total
#!/bin/bash
for i in {1..1000}; do
echo "hello world" | sed 's/lo//'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment