/* Lecture Code 5.4 * * Time trial of the deque against the vector using the push_back function. * Refer to 5.2 or 5.3 for information on the tricky syntax. */ #include #include #include #include using namespace std; const int NUM_ELEMS = 100000; const int NUM_TESTS = 500; template 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.push_back(i); for(int h = 0; h < NUM_ELEMS; h++) myContainer.pop_back(); } start = clock() - start; cout << "Test completed in "; cout << ((double)(start) / CLOCKS_PER_SEC); cout << " seconds." << endl; } int main() { RunTest >(); RunTest >(); return 0; }