/* Lecture code 10.1
 *
 * Time trial between the STL set and the Boost unordered_set.  Note that you must
 * have Boost installed on your system for this code to run.
 */

#include <iostream>
#include <set>
#include <boost/unordered_set.hpp>
#include <ctime>
using namespace std;
using namespace boost;

const int NUM_ELEMS = 10000;
const int NUM_TESTS = 5000;

template <typename ContainerType>
	void RunTest()
{
	clock_t start = clock();
	ContainerType myContainer;

	for(int h = 0; h < NUM_TESTS; h++)
	{
		for(int i = 0; i < NUM_ELEMS; i++)
			myContainer.insert(i);
	}

	start = clock() - start;

	cout << "Test completed in ";
	cout << ((double)(start) / CLOCKS_PER_SEC);
	cout << " seconds." << endl;
}

int main()
{
	RunTest<set<int> >();
	RunTest<unordered_set<int> >();
	return 0;
}