Created
September 4, 2011 19:25
-
-
Save RichardBronosky/1193377 to your computer and use it in GitHub Desktop.
test the speed of various hashing programs (and dd sources of random data)
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
| tests=3 | |
| kilobytes=102400 | |
| commands=(md5 shasum) | |
| count=0 | |
| test_num=0 | |
| time_file=/tmp/time.out | |
| file_base=/tmp/rand | |
| while [[ test_num -lt tests ]]; do | |
| ((test_num++)) | |
| for cmd in "${commands[@]}"; do | |
| ((count++)) | |
| file=$file_base$count | |
| touch $file | |
| # slowest | |
| #/usr/bin/time dd if=/dev/random of=$file bs=1024 count=$kilobytes >/dev/null 2>$time_file | |
| # slow | |
| #/usr/bin/time dd if=/dev/urandom of=$file bs=1024 count=$kilobytes >/dev/null 2>$time_file | |
| # less slow | |
| /usr/bin/time sudo dd if=/dev/disk0 skip=$(($RANDOM*4096)) of=$file bs=1024 count=$kilobytes >/dev/null 2>$time_file | |
| echo "dd took $(tail -n1 $time_file | awk '{print $1}') seconds" | |
| echo -n "$(printf "%7s" $cmd)ing $file: " | |
| /usr/bin/time $cmd $file >/dev/null | |
| rm $file | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment