#include "PmergeMe.hpp" #include #include #include #include #include #include #include #include template void display(const T& array) { for (size_t i = 0; i != array.size(); i++) std::cout << array[i] << " "; } int main(int ac, char** av) { { std::vector array; for (int i = 1; i != ac; i++) { for (int j = 0; av[i][j] != '\0'; j++) { if (j == 0 || av[i][j] == ' ') array.push_back(atoi(av[i] + j + (j != 0))); if (!std::isdigit(av[i][j]) and av[i][j] != ' ') { std::cout << "Error" << std::endl; return 1; } } } if (array.size() > 0) array.pop_back(); std::cout << "Before: "; display(array); std::cout << std::endl; const clock_t time_vec_start = clock(); PmergeMe(array); const clock_t time_vec_stop = clock(); std::cout << "After: "; display(array); std::cout << std::endl; std::cout << "Time to process a range of " << array.size() <<" elements with std::vector : " << ((double) (time_vec_stop - time_vec_start) / CLOCKS_PER_SEC) * 1000000 << " us" << std::endl; } { std::deque array; for (int i = 1; i != ac; i++) { for (int j = 0; av[i][j] != '\0'; j++) { if (j == 0 || av[i][j] == ' ') array.push_back(atoi(av[i] + j + (j != 0))); else if (!std::isdigit(av[i][j])) { std::cout << "Error" << std::endl; return 1; } } } if (array.size() > 0) array.pop_back(); const clock_t time_deque_start = clock(); PmergeMe(array); const clock_t time_deque_stop = clock(); std::cout << "Time to process a range of " << array.size() <<" elements with std::vector : " << ((double) (time_deque_stop - time_deque_start) / CLOCKS_PER_SEC) * 1000000 << " us" << std::endl; } }