From d8d4f48375bdef25d0bf445796eca300e47c9a07 Mon Sep 17 00:00:00 2001 From: Robin Nehls Date: Sat, 21 May 2011 17:07:28 +0200 Subject: added cmd line options (recompiling suxx) --- cacheRows2.c | 58 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/cacheRows2.c b/cacheRows2.c index e6295f6..d10c3bb 100644 --- a/cacheRows2.c +++ b/cacheRows2.c @@ -2,37 +2,49 @@ #include #include "inlineasm.h" -#define FIELD_SIZE 5000 -#define MIN_TIME 120 -#define MAX_TIME 1000 - -int main(int argc, char* argv[]) -{ - char *field1 = malloc(FIELD_SIZE); - char *field2 = malloc(FIELD_SIZE); +int main(int argc, char* argv[]) +{ + if (argc != 5) { + printf("Usage: %s \n",argv[0]); + return 1; + } + + unsigned long i,j,time,fieldsize,minticks,maxticks; + + sscanf(argv[1],"%lu",&fieldsize); + sscanf(argv[2],"%lu",&minticks); + sscanf(argv[3],"%lu",&maxticks); + + char *field1 = malloc(fieldsize); + char *field2 = malloc(fieldsize); char *current = field1; - unsigned long i,j; - unsigned long time=0; - FILE *f=stdout; + FILE *f; + + if (argv[4][0] == '-') { + f=stdout; + } + else { + f=fopen(argv[4],"w"); + } - // fill arrays with crap - for (i=0;i < FIELD_SIZE; ++i) { - field1[i]=(i+2342) % 255; + // fill arrays with crap + for (i=0;i < fieldsize; ++i) { + field1[i]=(i+2342) % 255; field2[i]=(i+4223) % 255; - } - + } + // print table reader if (argc == 1) { f=fopen("output.dat","w"); fprintf(f,"Offset Ticks\n"); } - for(i=0; i MIN_TIME ) + for(i=0; i minticks ) fprintf(f,"%lu %lu\n",i,time); - // scrambeled eggs + // scrambeled eggs if (current == field1) { current = field2; } @@ -40,9 +52,9 @@ int main(int argc, char* argv[]) current = field1; } - } + } fclose(f); - - return 0; + + return 0; } -- cgit v1.2.3-1-g7c22