Last active
August 22, 2017 11:35
-
-
Save lamcw/900c714eef93e87060634e0ff8f4ee0a to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
printf "Input\tInitial\tHas\tNumber\tAvgTime\tAvgTime\n" | |
printf "Size\tOrder\tDups\tof runs\tforusel\tforsort\n" | |
N_RUN=$1 | |
START_SIZE=$2 | |
END_SIZE=$3 | |
STEP=$4 | |
sortarg=( "-R" "-n" "-nr" ) | |
dups=( "no" "yes" ) | |
orders=( "random" "sorted" "reverse" ) | |
gen_dup () | |
{ | |
./randl $1 | sort ${sortarg[$2]} > nums | |
} | |
gen_no_dup () | |
{ | |
seq $1 | sort ${sortarg[$2]} > nums | |
} | |
for ((size=$START_SIZE; size<=$END_SIZE; size=size+$STEP)) | |
do | |
for dup in ${dups[@]} | |
do | |
for order in {0..2} | |
do | |
let utt=0 | |
let stt=0 | |
for ((i=1; i<=$N_RUN; i++)) | |
do | |
if [ "${dup}" == "no" ] | |
then | |
gen_no_dup $size $order | |
else | |
gen_dup $size $order | |
fi | |
uselt=$(time -f %U ./usel < nums 2>&1 1> /dev/null) | |
sortt=$(time -f %U sort -n < nums 2>&1 1> /dev/null) | |
utt="${utt}+${uselt}" | |
stt="${stt}+${sortt}" | |
rm -rf nums | |
done | |
utt="$(echo "($utt)/$N_RUN" | bc -l)" | |
stt="$(echo "($stt)/$N_RUN" | bc -l)" | |
printf "%d\t%s\t%s\t%d\t%.2fs\t%.2fs\n" "$size" "${orders[$order]}" "${dup}" "$N_RUN" "$utt" "$stt" | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment