summaryrefslogtreecommitdiffstats
path: root/cacheRows2.c
blob: d10c3bbc78b65ec1b7cf15718aa638891cfb0d37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <stdlib.h>
#include "inlineasm.h"

int main(int argc, char* argv[])
{
    if (argc != 5) {
        printf("Usage: %s <fieldsize> <minticks> <maxticks> <outputfile>\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;
    FILE *f;

    if (argv[4][0] == '-') {
        f=stdout;
    }
    else {
        f=fopen(argv[4],"w");
    }

    // 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<fieldsize; ++i) {
        time=memmeasure(current,i);
        if (time < maxticks && time > minticks )
            fprintf(f,"%lu %lu\n",i,time);

        // scrambeled eggs
        if (current == field1) {
            current = field2;
        }
        else {
            current = field1;
        }

    }
    fclose(f);

    return 0;
}