michael@0: #!/bin/sh michael@0: # michael@0: # multest michael@0: # michael@0: # Run multiply and square timing tests, to compute a chart for the michael@0: # current processor and compiler combination. michael@0: michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ECHO=/bin/echo michael@0: MAKE=gmake michael@0: michael@0: $ECHO "\n** Running multiply and square timing tests\n" michael@0: michael@0: $ECHO "Bringing 'mulsqr' up to date ... " michael@0: if $MAKE mulsqr ; then michael@0: : michael@0: else michael@0: $ECHO "\nMake failed to build mulsqr.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -x ./mulsqr ] ; then michael@0: $ECHO "\nCannot find 'mulsqr' program, testing cannot continue.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: sizes='64 128 192 256 320 384 448 512 640 768 896 1024 1536 2048' michael@0: ntests=500000 michael@0: michael@0: $ECHO "Running timing tests, please wait ... " michael@0: michael@0: trap 'echo "oop!";rm -f tt*.tmp;exit 0' INT HUP michael@0: michael@0: touch tt$$.tmp michael@0: $ECHO $ntests tests >> tt$$.tmp michael@0: for size in $sizes ; do michael@0: $ECHO "$size bits ... \c" michael@0: set -A res `./mulsqr $ntests $size|head -3|tr -d '%'|awk '{print $2}'` michael@0: $ECHO $size"\t"${res[0]}"\t"${res[1]}"\t"${res[2]} >> tt$$.tmp michael@0: $ECHO "(done)" michael@0: done michael@0: mv tt$$.tmp mulsqr-results.txt michael@0: rm -f tt$$.tmp michael@0: michael@0: $ECHO "\n** Running Karatsuba-Ofman multiplication tests\n" michael@0: michael@0: $ECHO "Brining 'karatsuba' up to date ... " michael@0: if $MAKE karatsuba ; then michael@0: : michael@0: else michael@0: $ECHO "\nMake failed to build karatsuba.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -x ./karatsuba ] ; then michael@0: $ECHO "\nCannot find 'karatsuba' program, testing cannot continue.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: ntests=100000 michael@0: michael@0: trap 'echo "oop!";rm -f tt*.tmp;exit 0' INT HUP michael@0: michael@0: touch tt$$.tmp michael@0: for size in $sizes ; do michael@0: $ECHO "$size bits ... " michael@0: ./karatsuba $ntests $size >> tt$$.tmp michael@0: tail -2 tt$$.tmp michael@0: done michael@0: mv tt$$.tmp karatsuba-results.txt michael@0: rm -f tt$$.tmp michael@0: michael@0: exit 0