Преглед изворни кода

2006-08-19 Aaron Bockover <[email protected]>

    * 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
Aaron Bockover пре 19 година
родитељ
комит
24f7344136
4 измењених фајлова са 79 додато и 4 уклоњено
  1. 9 0
      eglib/ChangeLog
  2. 16 1
      eglib/test/README
  3. 13 3
      eglib/test/driver.c
  4. 41 0
      eglib/test/test-both

+ 9 - 0
eglib/ChangeLog

@@ -1,3 +1,12 @@
+2006-08-19  Aaron Bockover  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* test/test.c: do not print times if -t is not passed

+ 16 - 1
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
+
+

+ 13 - 3
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) {

+ 41 - 0
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 $@