131 const int NUM_OPERATIONS = 1000000;
132 std::cout <<
"--- Performance Test (" << NUM_OPERATIONS <<
" push/pop operations) ---" <<
std::endl;
136 clock_t start_deque = clock();
137 for (
int i = 0; i < NUM_OPERATIONS; ++i) {
138 stack_with_deque.
push(i);
140 for (
int i = 0; i < NUM_OPERATIONS; ++i) {
141 stack_with_deque.
pop();
143 clock_t end_deque = clock();
144 double duration_deque =
static_cast<double>(end_deque - start_deque) / CLOCKS_PER_SEC;
145 std::cout <<
"Internal container std::deque: " << duration_deque <<
" seconds" <<
std::endl;
149 clock_t start_vector = clock();
150 for (
int i = 0; i < NUM_OPERATIONS; ++i) {
151 stack_with_vector.
push(i);
153 for (
int i = 0; i < NUM_OPERATIONS; ++i) {
154 stack_with_vector.
pop();
156 clock_t end_vector = clock();
157 double duration_vector =
static_cast<double>(end_vector - start_vector) / CLOCKS_PER_SEC;
158 std::cout <<
"Internal container std::vector: " << duration_vector <<
" seconds" <<
std::endl;
162 clock_t start_list = clock();
163 for (
int i = 0; i < NUM_OPERATIONS; ++i) {
164 stack_with_list.
push(i);
166 for (
int i = 0; i < NUM_OPERATIONS; ++i) {
167 stack_with_list.
pop();
169 clock_t end_list = clock();
170 double duration_list =
static_cast<double>(end_list - start_list) / CLOCKS_PER_SEC;
171 std::cout <<
"Internal container std::list: " << duration_list <<
" seconds" <<
std::endl;
void reverse_iterator_test()
Tests the behaviour of reverse iterators.
void performanceTest()
Test to compare performance using internal containers.
void list_comparison_test()
Test comparing MutantStack's behaviour with std::list.
void subject_main_test()
Basic test cases specified in the assignment.