Example #1
0
int main()
{
	//std::ofstream fout("Tests.txt");
	PRNG randoms;
	//Build vector of functions for later use
	std::vector<void (*)(std::vector<int>&, bool, std::ostream&)> fasts;
	fasts.push_back(NaiveQuickSort);
	fasts.push_back(QuickSortMedian);
	fasts.push_back(QuickSort);

	//Test the multithreaded algorithms
	cout <<"\n----Testing Algorithms----\n";
	for(unsigned int i = 0; i < fasts.size(); i++)
	{
		//Build test vectors
		std::vector<int> rands;
		for(unsigned int j = 0; j < 10000000; j++)
		{
			rands.push_back(randoms.randInt());
		}
		if(i==0)
			cout << "Naive Algorithm----\n";
		if(i==1)
			cout << "Adding Median of Three----\n";
		if(i==2)
			cout << "Multithreading, Median of Three, ShellSort on small data---\n";
		SortOperation(rands, fasts[i], cout);
		cout << "\n";
	}
	//Test the std::sort method as well
	std::vector<int> rands;
	for(unsigned int j = 0; j < 10000000; j++)
	{
		rands.push_back(randoms.randInt());
	}
	cout << "Testing std::sort---\n";
	clock_t start = clock();
	std::sort(rands.begin(),rands.end());
	clock_t finish = clock();
	cout << (static_cast<double>(finish - start) / static_cast<double>(CLOCKS_PER_SEC));
	cout << std::endl;

	//fout.close();
	system("PAUSE");
	return 0;
}