]> mj.ucw.cz Git - libucw.git/blobdiff - debug/sorter/radix-tune-bits.sh
Just for fun: Added heapsort to the sorting benchmark.
[libucw.git] / debug / sorter / radix-tune-bits.sh
index baab6df85768addbd1b171c541a7636f6a09808b..dbaa49c1a887d75240051287774be02002bf5ff4 100644 (file)
@@ -7,7 +7,7 @@ UCW_PROGNAME="$0"
 
 # Path to Sherlock build directory
 [ -n "$BUILD" ] || BUILD=..
-[ -f "$BUILD/lib/sorter/sorter.h" ] || die "BUILD does not point to Sherlock build directory"
+[ -f "$BUILD/ucw/sorter/sorter.h" ] || die "BUILD does not point to Sherlock build directory"
 
 # Find out sort buffer size
 parse-config 'Sorter{##SortBuffer}'
@@ -20,7 +20,10 @@ SIZE=$(($SORTBUF/2 - 8192))
 log "Decided to benchmark sorting of $SIZE byte data"
 
 # Which bit widths we try
-WIDTHS="6 7 8 9 10 11 12 13 14"
+WIDTHS="0 6 7 8 9 10 11 12 13 14"
+
+# Which RadixThresholds we try
+THRS="2000 4000 10000 20000 50000"
 
 # Which sort-test tests we try
 TESTS="2,5,8,15"
@@ -28,18 +31,33 @@ TESTS="2,5,8,15"
 # Check various bit widths of the radix sorter
 rm -f tmp/radix-*
 for W in $WIDTHS ; do
-       log "Compiling with $W-bit radix splits"
-       rm -f $BUILD/obj/lib/sorter/sort-test{,.o}
-       ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test )
-       log "Running the tests"
-       $BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v 2>&1 | tee tmp/radix-$W
+       rm -f $BUILD/obj/ucw/sorter/sort-test{,.o}
+       if [ $W = 0 ] ; then
+               log "Compiling with no radix splits"
+               ( cd $BUILD && make obj/ucw/sorter/sort-test )
+               OPT="-d32"
+       else
+               log "Compiling with $W-bit radix splits"
+               ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/ucw/sorter/sort-test )
+               OPT=
+       fi
+       for THR in $THRS ; do
+               log "Testing with RadixThreshold=$THR"
+               $BUILD/obj/ucw/sorter/sort-test -SThreads.DefaultStackSize=2M -SSorter.RadixThreshold=$THR -s$SIZE -t$TESTS $OPT -v 2>&1 | tee -a tmp/radix-$W
+       done
 done
 
-log "Trying with radix-sort switched off"
-$BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v -d32 2>&1 | tee tmp/radix-0
+echo "thresh" >tmp/radix-thrs
+echo "test#" >tmp/radix-tests
+for THR in $THRS ; do
+       for TEST in `echo $TESTS | tr ',' ' '` ; do
+               echo $THR >>tmp/radix-thrs
+               echo $TEST >>tmp/radix-tests
+       done
+done
 
-FILES=""
-for W in $WIDTHS ; do
+FILES="tmp/radix-thrs tmp/radix-tests"
+for W in $WIDTHS ; do
        a=tmp/radix-$W
        echo >$a.out "$W bits"
        sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
@@ -47,5 +65,4 @@ for W in 0 $WIDTHS ; do
 done
 
 log "These are the results:"
-echo "test#,$TESTS" | tr , '\n' >tmp/radix-tests
-paste tmp/radix-tests $FILES
+paste $FILES