test-both 2.0 KB

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