security/nss/lib/freebl/mpi/multest

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/mpi/multest	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# multest
     1.7 +#
     1.8 +# Run multiply and square timing tests, to compute a chart for the
     1.9 +# current processor and compiler combination.
    1.10 +
    1.11 +# This Source Code Form is subject to the terms of the Mozilla Public
    1.12 +# License, v. 2.0. If a copy of the MPL was not distributed with this
    1.13 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
    1.14 +
    1.15 +ECHO=/bin/echo
    1.16 +MAKE=gmake
    1.17 +
    1.18 +$ECHO "\n** Running multiply and square timing tests\n"
    1.19 +
    1.20 +$ECHO "Bringing 'mulsqr' up to date ... "
    1.21 +if $MAKE mulsqr ; then
    1.22 +    :
    1.23 +else
    1.24 +    $ECHO "\nMake failed to build mulsqr.\n"
    1.25 +    exit 1
    1.26 +fi
    1.27 +
    1.28 +if [ ! -x ./mulsqr ] ; then
    1.29 +    $ECHO "\nCannot find 'mulsqr' program, testing cannot continue.\n"
    1.30 +    exit 1
    1.31 +fi
    1.32 +
    1.33 +sizes='64 128 192 256 320 384 448 512 640 768 896 1024 1536 2048'
    1.34 +ntests=500000
    1.35 +
    1.36 +$ECHO "Running timing tests, please wait ... "
    1.37 +
    1.38 +trap 'echo "oop!";rm -f tt*.tmp;exit 0' INT HUP
    1.39 +
    1.40 +touch tt$$.tmp
    1.41 +$ECHO $ntests tests >> tt$$.tmp
    1.42 +for size in $sizes ; do
    1.43 +    $ECHO "$size bits ... \c"
    1.44 +    set -A res `./mulsqr $ntests $size|head -3|tr -d '%'|awk '{print $2}'`
    1.45 +    $ECHO $size"\t"${res[0]}"\t"${res[1]}"\t"${res[2]} >> tt$$.tmp
    1.46 +    $ECHO "(done)"
    1.47 +done
    1.48 +mv tt$$.tmp mulsqr-results.txt
    1.49 +rm -f tt$$.tmp
    1.50 +
    1.51 +$ECHO "\n** Running Karatsuba-Ofman multiplication tests\n"
    1.52 +
    1.53 +$ECHO "Brining 'karatsuba' up to date ... "
    1.54 +if $MAKE karatsuba ; then
    1.55 +    :
    1.56 +else
    1.57 +    $ECHO "\nMake failed to build karatsuba.\n"
    1.58 +    exit 1
    1.59 +fi
    1.60 +
    1.61 +if [ ! -x ./karatsuba ] ; then
    1.62 +    $ECHO "\nCannot find 'karatsuba' program, testing cannot continue.\n"
    1.63 +    exit 1
    1.64 +fi
    1.65 +
    1.66 +ntests=100000
    1.67 +
    1.68 +trap 'echo "oop!";rm -f tt*.tmp;exit 0' INT HUP
    1.69 +
    1.70 +touch tt$$.tmp
    1.71 +for size in $sizes ; do
    1.72 +    $ECHO "$size bits ... "
    1.73 +    ./karatsuba $ntests $size >> tt$$.tmp
    1.74 +    tail -2 tt$$.tmp
    1.75 +done
    1.76 +mv tt$$.tmp karatsuba-results.txt
    1.77 +rm -f tt$$.tmp
    1.78 +
    1.79 +exit 0

mercurial