1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Initial checkin of ary3 "benchmark" from prog lang shootout

llvm-svn: 1051
This commit is contained in:
Chris Lattner 2001-10-30 22:17:57 +00:00
parent 1474ad4c46
commit 66a557994b

41
test/ary3.c Normal file
View File

@ -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);
}