Created
March 29, 2013 22:09
-
-
Save Arkham/5274023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void measureSort(const char *name, void (*sortFunction)(int *, int)) { | |
clock_t start,end; | |
double period; | |
int array[MAX]; | |
initRand(array, MAX); | |
start = get_clock(); | |
(*sortFunction)(array, MAX); | |
end = get_clock(); | |
period = difftime(end, start); | |
printf ("%s time: %.lf ms\n", name, period); | |
} | |
int main(int argc, char *argv[]) { | |
srand(time(NULL)); | |
measureSort("selection", &selection_sort); | |
measureSort("bubble", &bubble_sort); | |
measureSort("insertion", &selection_sort); | |
measureSort("quicksort", &quicksort); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment