038c927eb258f20a998739c1473e7789a6674d0b
[mono.git] / eglib / test / test-both
1 #!/bin/sh
2
3 for arg in $@; do 
4         if [ "x$arg" = "x--help" ]; then
5                 echo "Usage: $0 [OPTION]... [ITERATIONS] [TESTGROUP]..."
6                 echo ""
7                 echo "Works the same as test-eglib or test-glib with the following"
8                 echo "exception. Run test-eglib --help for details on normal testing"
9                 echo ""
10                 echo "If the first OPTION is --speed-compare, the following is"
11                 echo "applicable to this program:"
12                 echo ""
13                 echo "  --speed-compare    run drivers in -qtni mode and report"
14                 echo "                     speed comparison information"
15                 echo ""
16                 echo "After --speed-compare, the number of iterations "
17                 echo "(optional, default is 100000) can be specified, followed "
18                 echo "by specific tests to run (or none to run all)"
19                 echo ""
20                 echo "If --speed-compare is not the first argument, all arguments are"
21                 echo "passed on directly to each driver"
22                 echo ""
23                 exit 1
24         fi
25 done
26
27 if [ ! -x "./test-glib" -o ! -x "./test-eglib" ]; then
28         make
29 fi
30
31 if [ "x$1" = "x--speed-compare" ]; then
32         ITERATIONS=100000
33         if [ ! -z "$2" ]; then
34                 case $2 in
35                         *[0-9]*) ITERATIONS=$2; break;
36                 esac
37         fi      
38
39         OPTIONS="-qnti $ITERATIONS"
40
41         for arg in $@; do
42                 if [ "x$arg" = "x--speed-compare" ]; then       
43                         continue;
44                 elif [ "$arg" = "$ITERATIONS" ]; then
45                         continue;
46                 fi
47
48                 OPTIONS="$OPTIONS $arg"
49         done
50         
51         echo "Running tests with $OPTIONS..."
52         
53         GLIB=`./test-glib $OPTIONS`
54         EGLIB=`./test-eglib $OPTIONS`
55
56         # this blows
57         FASTER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 < $3) print $2; else print $4 }'`
58         FASTER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 < $2) print $1; else print $2 }'`
59         SLOWER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 > $3) print $2; else print $4 }'`
60         SLOWER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 > $2) print $1; else print $2 }'`
61
62         FASTER_PERCENTAGE=`echo "$SLOWER_SPEED $FASTER_SPEED" | awk '{ print ($1 / $2) * 100 }'`
63
64         echo "$FASTER_NAME $FASTER_SPEED"
65         echo "$SLOWER_NAME $SLOWER_SPEED"
66         echo "------------------------------------------------"
67         echo "$FASTER_NAME is $FASTER_PERCENTAGE% faster than $SLOWER_NAME"
68         
69         exit 0;
70 fi
71
72 ./test-eglib $@
73 ./test-glib $@
74