Skip to content

Instantly share code, notes, and snippets.

@pprince
Forked from anonymous/results.txt
Last active March 28, 2016 13:06
Show Gist options
  • Save pprince/4ee6bfc4cc2e98e2e852 to your computer and use it in GitHub Desktop.
Save pprince/4ee6bfc4cc2e98e2e852 to your computer and use it in GitHub Desktop.
Going to run: find /usr -name "*c*" -type f -exec cat {} \; | wc -l
0.23s user 0.91s system 17% cpu 6.468 total
0.34s user 0.87s system 18% cpu 6.659 total
0.27s user 0.87s system 17% cpu 6.527 total
0.31s user 0.89s system 17% cpu 6.777 total
0.29s user 0.96s system 17% cpu 6.928 total
Going to run: find /usr -name "*c*" -type f -exec cat {} + | wc -l
0.14s user 0.32s system 95% cpu 0.484 total
0.14s user 0.20s system 94% cpu 0.360 total
0.12s user 0.23s system 93% cpu 0.371 total
0.10s user 0.22s system 86% cpu 0.361 total
0.15s user 0.17s system 93% cpu 0.345 total
Going to run: find /usr -name "*c*" -type f -print0 | xargs -0 cat | wc -l
0.13s user 0.20s system 93% cpu 0.355 total
0.13s user 0.19s system 92% cpu 0.346 total
0.15s user 0.20s system 93% cpu 0.372 total
0.14s user 0.19s system 94% cpu 0.355 total
0.15s user 0.18s system 92% cpu 0.358 total
Going to run: for i in /usr/**/*c*(.) ; do cat $i; done | wc -l
0.12s user 0.06s system 1% cpu 9.121 total
0.11s user 0.06s system 1% cpu 9.267 total
0.08s user 0.10s system 1% cpu 9.554 total
0.08s user 0.09s system 1% cpu 9.236 total
0.10s user 0.08s system 1% cpu 9.692 total
#!/usr/bin/zsh
SHELL=/usr/bin/zsh
do_perf () {
printf "Going to run: %s\n" "$1"
for i in {1..5}; do
# To check that all versions do the same thing,
# remove the '>/dev/null'.
time $SHELL -c "$1" >/dev/null
done
printf "\n"
}
# cache stuff:
find /usr -name "*c*" -exec cat {} \; >/dev/null 2>&1
printf "\n"
do_perf 'find /usr -name "*c*" -type f -exec cat {} \; | wc -l'
do_perf 'find /usr -name "*c*" -type f -exec cat {} + | wc -l'
do_perf 'find /usr -name "*c*" -type f -print0 | xargs -0 cat | wc -l'
do_perf 'for i in /usr/**/*c*(.) ; do cat $i; done | wc -l'
printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment