|
1 #!/bin/sh |
|
2 # |
|
3 # multest |
|
4 # |
|
5 # Run multiply and square timing tests, to compute a chart for the |
|
6 # current processor and compiler combination. |
|
7 |
|
8 # This Source Code Form is subject to the terms of the Mozilla Public |
|
9 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
10 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
11 |
|
12 ECHO=/bin/echo |
|
13 MAKE=gmake |
|
14 |
|
15 $ECHO "\n** Running multiply and square timing tests\n" |
|
16 |
|
17 $ECHO "Bringing 'mulsqr' up to date ... " |
|
18 if $MAKE mulsqr ; then |
|
19 : |
|
20 else |
|
21 $ECHO "\nMake failed to build mulsqr.\n" |
|
22 exit 1 |
|
23 fi |
|
24 |
|
25 if [ ! -x ./mulsqr ] ; then |
|
26 $ECHO "\nCannot find 'mulsqr' program, testing cannot continue.\n" |
|
27 exit 1 |
|
28 fi |
|
29 |
|
30 sizes='64 128 192 256 320 384 448 512 640 768 896 1024 1536 2048' |
|
31 ntests=500000 |
|
32 |
|
33 $ECHO "Running timing tests, please wait ... " |
|
34 |
|
35 trap 'echo "oop!";rm -f tt*.tmp;exit 0' INT HUP |
|
36 |
|
37 touch tt$$.tmp |
|
38 $ECHO $ntests tests >> tt$$.tmp |
|
39 for size in $sizes ; do |
|
40 $ECHO "$size bits ... \c" |
|
41 set -A res `./mulsqr $ntests $size|head -3|tr -d '%'|awk '{print $2}'` |
|
42 $ECHO $size"\t"${res[0]}"\t"${res[1]}"\t"${res[2]} >> tt$$.tmp |
|
43 $ECHO "(done)" |
|
44 done |
|
45 mv tt$$.tmp mulsqr-results.txt |
|
46 rm -f tt$$.tmp |
|
47 |
|
48 $ECHO "\n** Running Karatsuba-Ofman multiplication tests\n" |
|
49 |
|
50 $ECHO "Brining 'karatsuba' up to date ... " |
|
51 if $MAKE karatsuba ; then |
|
52 : |
|
53 else |
|
54 $ECHO "\nMake failed to build karatsuba.\n" |
|
55 exit 1 |
|
56 fi |
|
57 |
|
58 if [ ! -x ./karatsuba ] ; then |
|
59 $ECHO "\nCannot find 'karatsuba' program, testing cannot continue.\n" |
|
60 exit 1 |
|
61 fi |
|
62 |
|
63 ntests=100000 |
|
64 |
|
65 trap 'echo "oop!";rm -f tt*.tmp;exit 0' INT HUP |
|
66 |
|
67 touch tt$$.tmp |
|
68 for size in $sizes ; do |
|
69 $ECHO "$size bits ... " |
|
70 ./karatsuba $ntests $size >> tt$$.tmp |
|
71 tail -2 tt$$.tmp |
|
72 done |
|
73 mv tt$$.tmp karatsuba-results.txt |
|
74 rm -f tt$$.tmp |
|
75 |
|
76 exit 0 |