summaryrefslogtreecommitdiffstats
path: root/cacheRows2.c
blob: e6295f6d3e58a81023262adb9b5ce86306327328 (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
#include <stdio.h>
#include <stdlib.h>
#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);
    char *current = field1;
    unsigned long i,j;
	unsigned long time=0;
    FILE *f=stdout;

	// fill arrays with crap
	for (i=0;i < FIELD_SIZE; ++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<FIELD_SIZE; ++i) {
		time=memmeasure(current,i);
		if (time < MAX_TIME && time > MIN_TIME )
            fprintf(f,"%lu %lu\n",i,time);

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

	}
    fclose(f);
	
	return 0;
}