I am trying to time the duration of various sorting algorithms and am using the following code to do so. It seems to work when I time a user input, but when I time the function, it always gives me 0. I started off with milliseconds, and then moved to microseconds and then nanoseconds.
Here is the code I am using:
auto t1 = std::chrono::high_resolution_clock::now();
quickSort(p, 0, numberofints-1);
auto t2 = std::chrono::high_resolution_clock::now();
cout << "quicksort took "<< std::chrono::duration_cast<chrono::nanoseconds>(t2-t1).count()<< " nanoseconds\n";