security/nss/lib/freebl/mpi/timetest

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/bin/sh
     3 # Simple timing test for the MPI library.  Basically, we use prime
     4 # generation as a timing test, since it exercises most of the pathways
     5 # of the library fairly heavily.  The 'primegen' tool outputs a line
     6 # summarizing timing results.  We gather these and process them for
     7 # statistical information, which is collected into a file.
     9 # This Source Code Form is subject to the terms of the Mozilla Public
    10 # License, v. 2.0. If a copy of the MPL was not distributed with this
    11 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
    13 # Avoid using built-in shell echoes
    14 ECHO=/bin/echo
    15 MAKE=gmake
    16 PERL=perl
    18 # Use a fixed seed so timings will be more consistent
    19 # This one is the 11th-18th decimal digits of 'e'
    20 #export SEED=45904523
    21 SEED=45904523; export SEED
    23 #------------------------------------------------------------------------
    25 $ECHO "\n** Running timing tests for MPI library\n"
    27 $ECHO "Bringing 'metime' up to date ... "
    28 if $MAKE metime ; then
    29     :
    30 else 
    31     $ECHO "\nMake failed to build metime.\n"
    32     exit 1
    33 fi
    35 if [ ! -x ./metime ] ; then 
    36     $ECHO "\nCannot find 'metime' program, testing cannot continue.\n"
    37     exit 1
    38 fi
    40 #------------------------------------------------------------------------
    42 $ECHO "Bringing 'primegen' up to date ... "
    43 if $MAKE primegen ; then
    44     :
    45 else
    46     $ECHO "\nMake failed to build primegen.\n"
    47     exit 1
    48 fi
    50 if [ ! -x ./primegen ] ; then
    51     $ECHO "\nCannot find 'primegen' program, testing cannot continue.\n"
    52     exit 1
    53 fi
    55 #------------------------------------------------------------------------
    57 rm -f timing-results.txt
    58 touch timing-results.txt
    60 sizes="256 512 1024 2048"
    61 ntests=10
    63 trap 'echo "oop!";rm -f tt*.tmp timing-results.txt;exit 0' INT HUP
    65 $ECHO "\n-- Modular exponentiation\n"
    66 $ECHO "Modular exponentiation:" >> timing-results.txt
    68 $ECHO "Running $ntests modular exponentiations per test:"
    69 for size in $sizes ; do
    70     $ECHO "- Gathering statistics for $size bits ... "
    71     secs=`./metime $ntests $size | tail -1 | awk '{print $2}'`
    72     $ECHO "$size: " $secs " seconds per op" >> timing-results.txt
    73     tail -1 timing-results.txt
    74 done
    76 $ECHO "<done>";
    78 sizes="256 512 1024"
    79 ntests=1
    81 $ECHO "\n-- Prime generation\n"
    82 $ECHO "Prime generation:" >> timing-results.txt
    84 $ECHO "Generating $ntests prime values per test:"
    85 for size in $sizes ; do
    86     $ECHO "- Gathering statistics for $size bits ... "
    87     ./primegen $size $ntests | grep ticks | awk '{print $7}' | tr -d '(' > tt$$.tmp
    88     $ECHO "$size:" >> timing-results.txt
    89     $PERL stats tt$$.tmp >> timing-results.txt
    90     tail -1 timing-results.txt
    91     rm -f tt$$.tmp
    92 done
    94 $ECHO "<done>"
    96 trap 'rm -f tt*.tmp timing-results.txt' INT HUP
    98 exit 0

mercurial