[llvm-commits] [test-suite] r117565 - in /test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort: Makefile benchmark.c
Andrew Trick
atrick at apple.com
Thu Oct 28 11:07:50 PDT 2010
Author: atrick
Date: Thu Oct 28 13:07:50 2010
New Revision: 117565
URL: http://llvm.org/viewvc/llvm-project?rev=117565&view=rev
Log:
Added command line arg to specify # times to sort before printing.
Default = 1000
Modified:
test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/Makefile
test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/benchmark.c
Modified: test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/Makefile?rev=117565&r1=117564&r2=117565&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/Makefile (original)
+++ test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/Makefile Thu Oct 28 13:07:50 2010
@@ -1,7 +1,8 @@
LEVEL = ../../../..
PROG = qbsort
+# repeat the sort loop 1000 times (these are really small lists).
+RUN_OPTIONS := 1000
LDFLAGS = -lm
-#RUN_OPTIONS +=
STDIN_FILENAME = $(PROJ_SRC_DIR)/benchmark.in3
HASH_PROGRAM_OUTPUT = 1
include $(LEVEL)/MultiSource/Makefile.multisrc
Modified: test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/benchmark.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/benchmark.c?rev=117565&r1=117564&r2=117565&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/benchmark.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/McCat/01-qbsort/benchmark.c Thu Oct 28 13:07:50 2010
@@ -26,9 +26,14 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "sort.h"
#include "readlist.h"
+#ifdef TIMEREPEAT
+#include <sys/time.h>
+#endif
+
BOOL LessThan(int x, int y);
BOOL LessThan(int x, int y)
@@ -36,13 +41,39 @@
return (x < y);
}
-int main()
+int main(int argc, char **argv)
{
int listno = 1;
int err;
LinkList *ll; /* ll = lINKED lIST */
List *l; /* l = lIST */
+ /* Andrew Trick: added "repeat" to measure performance, not just correctness.
+ * This also required adding origList. */
+ int repeat = 0;
+ int *origList;
+ if (argc > 1) {
+ repeat = strtol(argv[1], 0, 0);
+ }
+#ifdef TIMEREPEAT
+ long long stime = 0;
+ struct timeval t, tt;
+#endif
while ((err = ReadList(&ll, &l)) == 0) {
+ origList = l->l;
+ l->l = (int*) malloc(sizeof(int)*l->n);
+ memcpy(l->l, origList, sizeof(int)*l->n);
+#ifdef TIMEREPEAT
+ gettimeofday(&t,0);
+#endif
+ for (; repeat > 0; --repeat) {
+ l = BubbleSort(l, LessThan);
+ memcpy(l->l, origList, sizeof(int)*l->n);
+ ll = QuickSort(ll, LessThan);
+ }
+#ifdef TIMEREPEAT
+ gettimeofday(&tt,0);
+ stime += (tt.tv_sec-t.tv_sec)*1000000 + (tt.tv_usec-t.tv_usec);
+#endif
printf("\nList read (reverse order): ");fflush(stdout);
PrintList(l);
printf("\nBubbleSort: "); fflush(stdout);
@@ -68,5 +99,8 @@
exit(1);
break;
}
+#ifdef TIMEREPEAT
+ printf("sort time = %lld usec\n", stime);
+#endif
exit(0);
}
More information about the llvm-commits
mailing list