Created
March 23, 2011 06:23
-
-
Save john-kurkowski/882702 to your computer and use it in GitHub Desktop.
Parallel Unix `sort` comparison
This file contains hidden or 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
#!/bin/bash | |
# Compare Mac OS X 10.6's `sort` to latest GNU Coreutils `sort` which parallelizes by default. | |
# More info: http://www.cs.ucla.edu/classes/fall10/cs35L/assign/assign9.html | |
integers=10000000 | |
file=`eval echo "~/Documents/integers1.txt"` | |
echo "Generating $integers integers..." | |
if [ ! -f $file ]; then | |
for i in $(eval echo "{1..$integers}"); do | |
echo $RANDOM | |
done > $file | |
fi | |
echo "Done. Now let's sort them." | |
time sort $file > /dev/null | |
time sort -n $file > /dev/null | |
time gsort $file > /dev/null | |
time gsort -n $file > /dev/null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment