security/nss/lib/freebl/mpi/timetest

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0b08be6d762b
1 #!/bin/sh
2
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.
8
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/.
12
13 # Avoid using built-in shell echoes
14 ECHO=/bin/echo
15 MAKE=gmake
16 PERL=perl
17
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
22
23 #------------------------------------------------------------------------
24
25 $ECHO "\n** Running timing tests for MPI library\n"
26
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
34
35 if [ ! -x ./metime ] ; then
36 $ECHO "\nCannot find 'metime' program, testing cannot continue.\n"
37 exit 1
38 fi
39
40 #------------------------------------------------------------------------
41
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
49
50 if [ ! -x ./primegen ] ; then
51 $ECHO "\nCannot find 'primegen' program, testing cannot continue.\n"
52 exit 1
53 fi
54
55 #------------------------------------------------------------------------
56
57 rm -f timing-results.txt
58 touch timing-results.txt
59
60 sizes="256 512 1024 2048"
61 ntests=10
62
63 trap 'echo "oop!";rm -f tt*.tmp timing-results.txt;exit 0' INT HUP
64
65 $ECHO "\n-- Modular exponentiation\n"
66 $ECHO "Modular exponentiation:" >> timing-results.txt
67
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
75
76 $ECHO "<done>";
77
78 sizes="256 512 1024"
79 ntests=1
80
81 $ECHO "\n-- Prime generation\n"
82 $ECHO "Prime generation:" >> timing-results.txt
83
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
93
94 $ECHO "<done>"
95
96 trap 'rm -f tt*.tmp timing-results.txt' INT HUP
97
98 exit 0
99

mercurial