security/nss/lib/freebl/mpi/timetest

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/mpi/timetest	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,99 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +# Simple timing test for the MPI library.  Basically, we use prime
     1.7 +# generation as a timing test, since it exercises most of the pathways
     1.8 +# of the library fairly heavily.  The 'primegen' tool outputs a line
     1.9 +# summarizing timing results.  We gather these and process them for
    1.10 +# statistical information, which is collected into a file.
    1.11 +
    1.12 +# This Source Code Form is subject to the terms of the Mozilla Public
    1.13 +# License, v. 2.0. If a copy of the MPL was not distributed with this
    1.14 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
    1.15 +
    1.16 +# Avoid using built-in shell echoes
    1.17 +ECHO=/bin/echo
    1.18 +MAKE=gmake
    1.19 +PERL=perl
    1.20 +
    1.21 +# Use a fixed seed so timings will be more consistent
    1.22 +# This one is the 11th-18th decimal digits of 'e'
    1.23 +#export SEED=45904523
    1.24 +SEED=45904523; export SEED
    1.25 +
    1.26 +#------------------------------------------------------------------------
    1.27 +
    1.28 +$ECHO "\n** Running timing tests for MPI library\n"
    1.29 +
    1.30 +$ECHO "Bringing 'metime' up to date ... "
    1.31 +if $MAKE metime ; then
    1.32 +    :
    1.33 +else 
    1.34 +    $ECHO "\nMake failed to build metime.\n"
    1.35 +    exit 1
    1.36 +fi
    1.37 +
    1.38 +if [ ! -x ./metime ] ; then 
    1.39 +    $ECHO "\nCannot find 'metime' program, testing cannot continue.\n"
    1.40 +    exit 1
    1.41 +fi
    1.42 +
    1.43 +#------------------------------------------------------------------------
    1.44 +
    1.45 +$ECHO "Bringing 'primegen' up to date ... "
    1.46 +if $MAKE primegen ; then
    1.47 +    :
    1.48 +else
    1.49 +    $ECHO "\nMake failed to build primegen.\n"
    1.50 +    exit 1
    1.51 +fi
    1.52 +
    1.53 +if [ ! -x ./primegen ] ; then
    1.54 +    $ECHO "\nCannot find 'primegen' program, testing cannot continue.\n"
    1.55 +    exit 1
    1.56 +fi
    1.57 +
    1.58 +#------------------------------------------------------------------------
    1.59 +
    1.60 +rm -f timing-results.txt
    1.61 +touch timing-results.txt
    1.62 +
    1.63 +sizes="256 512 1024 2048"
    1.64 +ntests=10
    1.65 +
    1.66 +trap 'echo "oop!";rm -f tt*.tmp timing-results.txt;exit 0' INT HUP
    1.67 +
    1.68 +$ECHO "\n-- Modular exponentiation\n"
    1.69 +$ECHO "Modular exponentiation:" >> timing-results.txt
    1.70 +
    1.71 +$ECHO "Running $ntests modular exponentiations per test:"
    1.72 +for size in $sizes ; do
    1.73 +    $ECHO "- Gathering statistics for $size bits ... "
    1.74 +    secs=`./metime $ntests $size | tail -1 | awk '{print $2}'`
    1.75 +    $ECHO "$size: " $secs " seconds per op" >> timing-results.txt
    1.76 +    tail -1 timing-results.txt
    1.77 +done
    1.78 +
    1.79 +$ECHO "<done>";
    1.80 +
    1.81 +sizes="256 512 1024"
    1.82 +ntests=1
    1.83 +
    1.84 +$ECHO "\n-- Prime generation\n"
    1.85 +$ECHO "Prime generation:" >> timing-results.txt
    1.86 +
    1.87 +$ECHO "Generating $ntests prime values per test:"
    1.88 +for size in $sizes ; do
    1.89 +    $ECHO "- Gathering statistics for $size bits ... "
    1.90 +    ./primegen $size $ntests | grep ticks | awk '{print $7}' | tr -d '(' > tt$$.tmp
    1.91 +    $ECHO "$size:" >> timing-results.txt
    1.92 +    $PERL stats tt$$.tmp >> timing-results.txt
    1.93 +    tail -1 timing-results.txt
    1.94 +    rm -f tt$$.tmp
    1.95 +done
    1.96 +
    1.97 +$ECHO "<done>"
    1.98 +
    1.99 +trap 'rm -f tt*.tmp timing-results.txt' INT HUP
   1.100 +
   1.101 +exit 0
   1.102 +

mercurial