Hi, has anyone ever written a program to characterize the speed of the various memory and stream functions in C? I'm not sure if this is the best way, but I am creating a timestamp by accessing the processor before I perform a function and after, then storing these timestamps.
EX:
Code:
char local[MEM_SIZE];
char *heap = NULL;
int i;
FILE *out;
InitMT();
heap = (char *)calloc(1, MEM_SIZE);
for (i = 0; i < NUM_TESTS; i++)
{
micro_time(&t[i][0]);
memset(local, 0, MEM_SIZE);
micro_time(&t[i][1]);
memset(heap, 0, MEM_SIZE);
micro_time(&t[i][2]);
memset(dataSeg, 0, MEM_SIZE);
micro_time(&t[i][3]);
}
Code:
#define NUM_TESTS 50000
char dataSeg[MEM_SIZE];
MICRO_TIME_TYPE t[NUM_TESTS][4];
Has anyone done something simliar? Is there a better way?
BTW: micro_time will take the argument and set it to the current time.
Thank You.
Steve