Skip to content

Instantly share code, notes, and snippets.

@john-kurkowski
Created March 23, 2011 06:23
Show Gist options
  • Save john-kurkowski/882702 to your computer and use it in GitHub Desktop.
Save john-kurkowski/882702 to your computer and use it in GitHub Desktop.
Parallel Unix `sort` comparison
#!/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