#include <iostream>
#include <cstdlib>
#include <ctime>
#include "row.hpp"

using namespace std;
int main() {

	srand(time(NULL));

	//array that stores the sizes for n=1000 and n=10000
	int test_sizes[2] = {1000, 10000};

	//loop for both
	for(int size_index = 0; size_index < 2; size_index++) {

		int n = test_sizes[size_index];
		cout << "\nTesting n = " << n << endl;

		//creates a dynamic array
		double *b = new double[n];

		//fills the array with random numbers from -10000 to 10000
		for(int i = 0; i < n; i++) {
			b[i] = -10000 + (rand() / (double)RAND_MAX) * 20000;
		}

		//creates a row object with the original given numbers
		row<double> original(b, n);

		//variables for measuring time
		clock_t start, end;
		double seconds;

		//bubble sort
		row<double> a1 = original;
		start = clock();
		bubble_sort(a1);
		end = clock();

		seconds = (double)(end - start) / CLOCKS_PER_SEC;
		cout << "Bubble: " << seconds << " sec" << endl;

		//selection sort
		row<double> a2 = original;
		start = clock();
		selection_sort(a2);
		end = clock();

		seconds = (double)(end - start) / CLOCKS_PER_SEC;
		cout << "Selection: " << seconds << " sec" << endl;

		//insertion sort
		row<double> a3 = original;
		start = clock();
		insertion_sort(a3);
		end = clock();

		seconds = (double)(end - start) / CLOCKS_PER_SEC;
		cout << "Insertion: " << seconds << " sec" << endl;

		//merge sort
		row<double> a4 = original;
		start = clock();
		merge_sort(a4);
		end = clock();

		seconds = (double)(end - start) / CLOCKS_PER_SEC;
		cout << "Merge: " << seconds << " sec" << endl;

		//quick sort
		row<double> a5 = original;
		start = clock();
		quick_sort(a5);
		end = clock();

		seconds = (double)(end - start) / CLOCKS_PER_SEC;
		cout << "Quick: " << seconds << " sec" << endl;

		//enumeration sort
		row<double> a6 = original;
		start = clock();
		enumeration_sort(a6);
		end = clock();

		seconds = (double)(end - start) / CLOCKS_PER_SEC;
		cout << "Enumeration: " << seconds << " sec" << endl;

		//free memory
		delete[] b;


	}

	return 0;


}
