Blame nss/lib/freebl/mpi/multest

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