#include #include #include #include #include #include #include #include using namespace std; class timer { public: timer() : start_timing(hi_res_clock::now()) {} void reset() { start_timing = hi_res_clock::now(); } double elapsed() const { return(std::chrono::duration_cast (hi_res_clock::now() - start_timing).count()); } private: typedef std::chrono::high_resolution_clock hi_res_clock; typedef std::chrono::duration > second_; std::chrono::time_point start_timing; }; void print_time(const string & heading , const double & t) { // Right justifies to column 30 const int nb=30; int n; int i; int l; l = heading.length(); if ( l >= nb ) cout << " Warning heading too long. Reduce to less than 30 characters" << endl; n=nb-l; cout << heading ; for (i=1;i & vector,int i, int j) { int tmp=vector[i]; vector[i]=vector[j]; vector[j]=tmp; } void quicksort(vector & vector, int l, int r) { int i=l; int j=r; int v=vector[int((l+r)/2)]; for (;;) { while (vector[i] < v) i=i+1; while (v < vector[j]) j=j-1; if (i<=j) { swap(vector,i,j); i=i+1 ; j=j-1; } if (i>j) goto ended ; } ended: ; if (l x(n); int i; int j; double t; default_random_engine random_engine; uniform_int_distribution integer_random(1,INT_MAX); timer timer_01; timer timer_02; heading = "Program starts"; t=timer_01.elapsed(); print_time( heading , t); heading = "default_random_engine"; for (j=0;j