Skip to content

Instantly share code, notes, and snippets.

@Arkham
Created March 29, 2013 22:09
Show Gist options
  • Save Arkham/5274023 to your computer and use it in GitHub Desktop.
Save Arkham/5274023 to your computer and use it in GitHub Desktop.
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