This is my code:
Code:
/*****************************************************************/
/* CS 2350 Spring 2007 */
/* C section for Assignment 5 */
/************************ include files **************************/
//65-90 97-122
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#define CLOCKS_PER_SEC 1000
//External functions/variables
extern "C" void lexsort(char*,char*);
//Global functions/variables
int COUNT;
int ITER = 0;
int main(void)
{
putchar('\n');
putchar(':');
scanf("%d", &COUNT);
//random-related statements/variables
srand(time(0));
int ran;
char* input = new char[COUNT+1];
char* output = new char[COUNT+1];
output[COUNT] = NULL;
input[COUNT] = NULL;
//time-related variables
struct timeval before, after;
double diff;
int x = 0;
while(x < COUNT)
{
ran = rand() % 57 + 65;
if(ran > 90 && ran < 122)
continue;
else
{
input[x++] = ran;
}
}
printf("input = %s\n\n", input);
//implement lexsort function
gettimeofday(&before, 0);
lexsort(input, output);
gettimeofday(&after, 0);
//diff = after.tv_nsec - before.tv_nsec;
//output results
printf("output = %s\n", output);
printf("Time to implement: %d", after.tv_usec);
printf("\nbefore = %d", before.tv_usec);
return 0;
}
Now, I really don't think my computer is fast enough to do a function in under 1 microsecond, (2.8 P4), but if thats the case, then I need a nanosecond timer.