/*cputest.c * Tyler Simon * 8/24/2010 * Do some CPU intensive work with quicksort * Print out usage per core getpinfo */ #include #include #include #include #include #include #include int ascending(const int *a, const int *b) { int temp = *a - *b; if (temp > 0) return 1; else if (temp < 0) return -1; else return 0; } int descending(const int *a, const int *b) { int temp = *a - *b; if (temp < 0) return 1; else if (temp > 0) return -1; else return 0; } double getCurrentTime(void) { struct timeval tval; gettimeofday(&tval, NULL); return (tval.tv_sec + tval.tv_usec/1000000.0); } //int main(int argc, char **argv){ double cpu_test(char *host,long int size, int tid){ int i; double start_time, end_time,fin_time; int *nums; srand(time(NULL)+tid); nums = (int *)malloc(sizeof(int) * size); if(!nums){ printf("ERROR ALLOCING MEM\n"); exit(1); } //printf("Populating %d element array with random numbers.\n", size); start_time = getCurrentTime(); for(i=0; i