#include #include #include #include #include "QuickSort.h" using namespace std; int main(int argc, char * argv[]) { int searchSize{10}; vector target{1,4,5 ,8,10,11,3,7,2,9,6}; vector standard(target); bool error {false}; int errors{0}; // see https://en.cppreference.com/w/cpp/chrono auto time1 = chrono::high_resolution_clock::now(); sort(begin(standard), end(standard)); auto time2 = chrono::high_resolution_clock::now(); QuickSort(target); auto time3 = chrono::high_resolution_clock::now(); chrono::duration dtime1 = time2 - time1, dtime2 = time3 - time2; cout << "Standard Library Time: " << dtime1.count() << " seconds." << endl; cout << "Quick Time: " << dtime2.count() << " seconds." << endl; cout << endl; // check and report any errors for(size_t i=0; i < standard.size(); i++) { if (standard[i] != target[i]) { cout << "Error at position " << i << endl; error = true; errors ++; } } if (error) { cout << "There were at total of " << errors << " misplaced elements" << endl; } for(int i =0; i < static_cast(target.size())-1; i++) { if (target[i] > target[i+1]) { cout << "Sort Error" << endl; return 1; } } return 0; }