From 24f7344136b48aedadbe2d2b892b31261a3fff89 Mon Sep 17 00:00:00 2001 From: Aaron Bockover Date: Sat, 19 Aug 2006 21:02:25 +0000 Subject: [PATCH] 2006-08-19 Aaron Bockover * test/driver.c: added -n mode to show only raw global run times, which is useful for scripts (test-both --speed-compare) * test/test-both: added --speed-compare mode * test/README: updated with information on --speed-compare svn path=/trunk/mono/; revision=64055 --- eglib/ChangeLog | 9 +++++++++ eglib/test/README | 17 ++++++++++++++++- eglib/test/driver.c | 16 +++++++++++++--- eglib/test/test-both | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 4 deletions(-) diff --git a/eglib/ChangeLog b/eglib/ChangeLog index 3d5aaac5677..fb3bf118cef 100644 --- a/eglib/ChangeLog +++ b/eglib/ChangeLog @@ -1,3 +1,12 @@ +2006-08-19 Aaron Bockover + + * test/driver.c: added -n mode to show only raw global run times, + which is useful for scripts (test-both --speed-compare) + + * test/test-both: added --speed-compare mode + + * test/README: updated with information on --speed-compare + 2006-08-19 Aaron Bockover * test/test.c: do not print times if -t is not passed diff --git a/eglib/test/README b/eglib/test/README index 61eed46dc77..7c28d03e954 100644 --- a/eglib/test/README +++ b/eglib/test/README @@ -92,7 +92,22 @@ Example: show test output of all available groups The 'test-both' script can be used to run both test-eglib and test-glib with the same options back to back: - $./test-both -tqi 100000 ptrarray + $ ./test-both -tqi 100000 ptrarray EGlib Total Time: 1.1961s GLib Total Time: 0.955957s +test-both also has a nice --speed-compare mode that shows comparison +information about EGlib vs GLib. It can run all tests or specific tests +with a configurable number of iterations. --speed-compare mode always runs +the drivers with -qtni + +The syntax for --speed-compare is: + + ./test-both --speed-compare [ITERATIONS] [GROUPS...] + + $ ./test-both --speed-compare Runs all tests with default iterations + $ ./test-both --speed-compare 500 Runs all tests with 500 iterations + $ ./test-both --speed-compare ptrarray Runs ptrarray test with default + iterations + + diff --git a/eglib/test/driver.c b/eglib/test/driver.c index 2319be28570..9bd3d80d31b 100644 --- a/eglib/test/driver.c +++ b/eglib/test/driver.c @@ -74,7 +74,9 @@ static void print_help(char *s) printf(" -t, --time time the tests\n"); printf(" -i, --iterations number of times to run tests\n"); printf(" -q, --quiet do not print test results; " - "time always prints\n\n"); + "final time always prints\n"); + printf(" -n print final time without labels, " + "nice for scripts\n\n"); printf("TESTGROUPS available:\n"); for(i = 0; test_groups[i].name != NULL; i++) { @@ -92,6 +94,7 @@ gint main(gint argc, gchar **argv) gboolean report_time = FALSE; gboolean quiet = FALSE; gboolean global_failure = FALSE; + gboolean no_final_time_labels = FALSE; static struct option long_options [] = { {"help", no_argument, 0, 'h'}, @@ -101,7 +104,7 @@ gint main(gint argc, gchar **argv) {0, 0, 0, 0} }; - while((c = getopt_long(argc, argv, "htqi:", long_options, NULL)) != -1) { switch(c) { + while((c = getopt_long(argc, argv, "htqni:", long_options, NULL)) != -1) { switch(c) { case 'h': print_help(argv[0]); return 1; @@ -114,6 +117,9 @@ gint main(gint argc, gchar **argv) case 'q': quiet = TRUE; break; + case 'n': + no_final_time_labels = TRUE; + break; } } @@ -158,7 +164,11 @@ gint main(gint argc, gchar **argv) if(report_time) { gdouble duration = get_timestamp() - time_start; - printf("%s Total Time: %g\n", DRIVER_NAME, duration); + if(no_final_time_labels) { + printf("%g\n", duration); + } else { + printf("%s Total Time: %g\n", DRIVER_NAME, duration); + } } if(tests_to_run != NULL) { diff --git a/eglib/test/test-both b/eglib/test/test-both index a006a43fdf9..fd3322d3a2b 100755 --- a/eglib/test/test-both +++ b/eglib/test/test-both @@ -1,5 +1,46 @@ #!/bin/sh +if [ "x$1" = "x--speed-compare" ]; then + ITERATIONS=100000 + if [ ! -z "$2" ]; then + case $2 in + *[0-9]*) ITERATIONS=$2; break; + esac + fi + + OPTIONS="-qnti $ITERATIONS" + + for arg in $@; do + if [ "x$arg" = "x--speed-compare" ]; then + continue; + elif [ "$arg" = "$ITERATIONS" ]; then + continue; + fi + + OPTIONS="$OPTIONS $arg" + done + + echo "Running tests with $OPTIONS..." + + GLIB=`./test-glib $OPTIONS` + EGLIB=`./test-eglib $OPTIONS` + + # this blows + FASTER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 < $3) print $2; else print $4 }'` + FASTER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 < $2) print $1; else print $2 }'` + SLOWER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 > $3) print $2; else print $4 }'` + SLOWER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 > $2) print $1; else print $2 }'` + + FASTER_PERCENTAGE=`echo "$SLOWER_SPEED $FASTER_SPEED" | awk '{ print ($1 / $2) * 100 }'` + + echo "$FASTER_NAME $FASTER_SPEED" + echo "$SLOWER_NAME $SLOWER_SPEED" + echo "------------------------------------------------" + echo "$FASTER_NAME is $FASTER_PERCENTAGE% faster than $SLOWER_NAME" + + exit 0; +fi + ./test-eglib $@ ./test-glib $@ -- 2.25.1