I just had a go at writing a program that times simple operations. It dosent seem to be working tho. I figured that this should take at least 1 millisecond to run:
Code:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
srand(time(NULL));
int *table1, *table2;
unsigned x, y, z;
unsigned time;
int mod, mul, add, sub, div;
int test;
table1=malloc(sizeof(int)*1000000);
table2=malloc(sizeof(int)*1000000);
while(*table1)
{
*table1=rand()+1;
table1++;
}
while(*table2)
{
*table2=rand()+1;
table2++;
}
time=clock();
while(*table1)
{
for(x=0; x<4294967295; x++)
for(y=0; y<4294967295; y++)
for(z=0; z<4294967295; z++)
test = *table1 % *table2;
table1++;
table2++;
}
mod=clock()-time;
printf("Modulus: %i\n", mod);
printf("X:%i Y:%i Z:%i", x, y, z);
getchar();
}
It dident, so I printed out the x, y, z variables and it seems as if the loops have just decided to exit at random times. I must be doing something wrong here. Right?