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.

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

mercurial