/* Lecture Code 2.7
 *
 * Time trial of vector vs deque for element access.  However, this time the container is declared inside
 * the outer loop, which has a major performance hit for the deque.
 * Refer to 2.2 or 2.3 for more info on tricky syntax.
 */

#include <iostream>
#include <vector>
#include <deque>
#include <ctime>
using namespace std;

const int NUM_ELEMS = 100000;
const int NUM_TESTS = 1000;

template <typename ContainerType>
	void RunTest()
{
	
	clock_t start = clock();
	
	for(int h = 0; h < NUM_TESTS; h++)
	{
		ContainerType myContainer(NUM_ELEMS);
		for(int i = 0; i < NUM_ELEMS; i++)
			myContainer[i] = i;
	}

	start = clock() - start;

	cout << "Test completed in ";
	cout << ((double)(start) / CLOCKS_PER_SEC);
	cout << " seconds." << endl;
}

int main()
{
	RunTest<vector<int> >();
	RunTest<deque<int> >();

	return 0;
}