Created
October 1, 2018 15:29
-
-
Save s-leroux/e12358746565de4ec84f59a94d505a9e to your computer and use it in GitHub Desktop.
A quick and dirty script to compare performances between passing an input file as a `file parameter`, as a `redirection` or using an `useless cat`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATAFILE="${HOME}/random.data" | |
SCRIPT=" | |
{ | |
/* simulate some processing */ | |
for(i = 0; i < rand()*1000; ++i) | |
acc += i; | |
} | |
" | |
for n in {00..99}; do | |
# Generate few MB of data | |
dd if=/dev/urandom of="${DATAFILE}" bs=1M count=500 conv=fdatasync oflag=nocache | |
# Drop cache | |
dd of="${DATAFILE}" count=0 conv=notrunc,fdatasync oflag=nocache | |
echo -e '\nA' | |
time \ | |
awk "${SCRIPT}" "${DATAFILE}" | |
# Drop cache | |
dd of="${DATAFILE}" count=0 conv=notrunc,fdatasync oflag=nocache | |
echo -e '\nB' | |
time \ | |
awk "${SCRIPT}" < "${DATAFILE}" | |
# Drop cache | |
dd of="${DATAFILE}" count=0 conv=notrunc,fdatasync oflag=nocache | |
echo -e '\nC' | |
time cat "${DATAFILE}" | \ | |
awk "${SCRIPT}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment