summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-30 22:17:57 +0000
committerChris Lattner <sabre@nondot.org>2001-10-30 22:17:57 +0000
commitdb351718d0ed151efadbe181e03c605ca869ed33 (patch)
tree8fe091b3f93c805657b10d547362f6f7699978a6 /test
parent4d0e1f96f495439c1e244e9714484b3d4b60826d (diff)
downloadllvm-db351718d0ed151efadbe181e03c605ca869ed33.tar.gz
llvm-db351718d0ed151efadbe181e03c605ca869ed33.tar.bz2
llvm-db351718d0ed151efadbe181e03c605ca869ed33.tar.xz
Initial checkin of ary3 "benchmark" from prog lang shootout
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/ary3.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ary3.c b/test/ary3.c
new file mode 100644
index 0000000000..3bb99f9362
--- /dev/null
+++ b/test/ary3.c
@@ -0,0 +1,41 @@
+/* -*- mode: c -*-
+ * $Id$
+ * http://www.bagley.org/~doug/shootout/
+ *
+ * this program is modified from:
+ * http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html
+ * Timing Trials, or, the Trials of Timing: Experiments with Scripting
+ * and User-Interface Languages</a> by Brian W. Kernighan and
+ * Christopher J. Van Wyk.
+ *
+ * I added free() to deallocate memory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[]) {
+ int n = ((argc == 2) ? atoi(argv[1]) : 1);
+ int i, k, *x, *y;
+
+ x = (int *) calloc(n, sizeof(int));
+ y = (int *) calloc(n, sizeof(int));
+
+ for (i = 0; i < n; i++) {
+ x[i] = i + 1;
+ }
+ for (k=0; k<1000; k++) {
+ for (i = n-1; i >= 0; i--) {
+ y[i] += x[i];
+ }
+ }
+
+ printf("%d %d\n", y[0], y[n-1]);
+
+ free(x);
+ free(y);
+
+ return(0);
+}
+