#include <iostream>
#include <cstdlib>
#include <ctime>
#include <boost/chrono.hpp>

#include "row.hpp"

using namespace std;

double random_double()
{
	return -10000 +(double)rand()/RAND_MAX * 20000;
}

void test(int n)
{
	double* b =new double[n];

	for (int i=0;i<n;i++)
		b[i] = random_double();
	cout << "\nFor n = " << n << endl;

	boost::chrono::high_resolution_clock::time_point start;
	boost::chrono::high_resolution_clock::time_point stop;
	boost::chrono::microseconds ms;

	row<double>* a1 = new row<double>(b,n);
	start = boost::chrono::high_resolution_clock::now();
	quick_sort(*a1);
	stop = boost::chrono::high_resolution_clock::now();
	ms = boost::chrono::duration_cast<boost::chrono::microseconds>(stop-start);
	cout << "Quick Time = " <<ms.count() << endl;
	delete a1;

	row<double>* a2 = new row<double>(b,n);
	start = boost::chrono::high_resolution_clock::now();
	bubble_sort(*a2);
	stop = boost::chrono::high_resolution_clock::now();
	ms = boost::chrono::duration_cast<boost::chrono::microseconds>(stop-start);
	cout << "Bubble Time = " <<ms.count() << endl;
	delete a2;

	row<double>* a3 = new row<double>(b,n);
	start = boost::chrono::high_resolution_clock::now();
	merge_sort(*a3);
	stop = boost::chrono::high_resolution_clock::now();
	ms = boost::chrono::duration_cast<boost::chrono::microseconds>(stop-start);
	cout << "Merge Time = " <<ms.count() << endl;
	delete a3;

	row<double>* a4 = new row<double>(b,n);
	start = boost::chrono::high_resolution_clock::now();
	selection_sort(*a4);
	stop = boost::chrono::high_resolution_clock::now();
	ms = boost::chrono::duration_cast<boost::chrono::microseconds>(stop-start);
	cout << "Selection Time = " <<ms.count() << endl;
	delete a4;

	row<double>* a5 = new row<double>(b,n);
	start = boost::chrono::high_resolution_clock::now();
	insertion_sort(*a5);
	stop = boost::chrono::high_resolution_clock::now();
	ms = boost::chrono::duration_cast<boost::chrono::microseconds>(stop-start);
	cout << "Insertion Time = " <<ms.count() << endl;
	delete a5;

	row<double>* a6 = new row<double>(b,n);
	start = boost::chrono::high_resolution_clock::now();
	enumeration_sort(*a6);
	stop = boost::chrono::high_resolution_clock::now();
	ms = boost::chrono::duration_cast<boost::chrono::microseconds>(stop-start);
	cout << "Enumeration Time = " <<ms.count() << endl;
	delete a6;
}

	int main() {
		srand((unsigned)time(NULL));

		test(1000);
		test(10000);

		return 0;
	}
	
