| 1 | // 2009-23-12 Paolo Carlini <[email protected]> |
| 2 | // |
| 3 | // This file is part of the GNU ISO C++ Library. This library is free |
| 4 | // software; you can redistribute it and/or modify it under the |
| 5 | // terms of the GNU General Public License as published by the |
| 6 | // Free Software Foundation; either version 3, or (at your option) |
| 7 | // any later version. |
| 8 | |
| 9 | // This library is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | |
| 14 | // You should have received a copy of the GNU General Public License along |
| 15 | // with this library; see the file COPYING3. If not see |
| 16 | // <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | #include <deque> |
| 19 | #include <vector> |
| 20 | #include <list> |
| 21 | |
| 22 | #include <testsuite_performance.h> |
| 23 | |
| 24 | int main() |
| 25 | { |
| 26 | using namespace __gnu_test; |
| 27 | |
| 28 | time_counter time; |
| 29 | resource_counter resource; |
| 30 | |
| 31 | const std::deque<int> data(3000, 3); |
| 32 | |
| 33 | std::deque<int> d(3000, 1); |
| 34 | |
| 35 | start_counters(time, resource); |
| 36 | for (int i = 0; i < 1000; ++i) |
| 37 | for (int j = 0; j < 3000; ++j) |
| 38 | std::copy(data.begin(), data.begin() + j, d.begin()); |
| 39 | stop_counters(time, resource); |
| 40 | report_performance(__FILE__, "deque 2 deque", time, resource); |
| 41 | clear_counters(time, resource); |
| 42 | |
| 43 | std::vector<int> v(3000, 1); |
| 44 | |
| 45 | start_counters(time, resource); |
| 46 | for (int i = 0; i < 1000; ++i) |
| 47 | for (int j = 0; j < 3000; ++j) |
| 48 | std::copy(data.begin(), data.begin() + j, v.begin()); |
| 49 | stop_counters(time, resource); |
| 50 | report_performance(__FILE__, "deque 2 vector", time, resource); |
| 51 | clear_counters(time, resource); |
| 52 | |
| 53 | d.assign(3000, 1); |
| 54 | |
| 55 | start_counters(time, resource); |
| 56 | for (int i = 0; i < 1000; ++i) |
| 57 | for (int j = 0; j < 3000; ++j) |
| 58 | std::copy(v.begin(), v.begin() + j, d.begin()); |
| 59 | stop_counters(time, resource); |
| 60 | report_performance(__FILE__, "vector 2 deque", time, resource); |
| 61 | clear_counters(time, resource); |
| 62 | |
| 63 | std::vector<char> cv(3000, 1); |
| 64 | |
| 65 | start_counters(time, resource); |
| 66 | for (int i = 0; i < 1000; ++i) |
| 67 | for (int j = 0; j < 3000; ++j) |
| 68 | std::copy(data.begin(), data.begin() + j, cv.begin()); |
| 69 | stop_counters(time, resource); |
| 70 | report_performance(__FILE__, "int deque 2 char vector", time, resource); |
| 71 | clear_counters(time, resource); |
| 72 | |
| 73 | d.assign(3000, 1); |
| 74 | |
| 75 | start_counters(time, resource); |
| 76 | for (int i = 0; i < 1000; ++i) |
| 77 | for (int j = 0; j < 3000; ++j) |
| 78 | std::copy(cv.begin(), cv.begin() + j, d.begin()); |
| 79 | stop_counters(time, resource); |
| 80 | report_performance(__FILE__, "char vector 2 int deque", time, resource); |
| 81 | clear_counters(time, resource); |
| 82 | |
| 83 | std::list<int> l(3000, 1); |
| 84 | |
| 85 | start_counters(time, resource); |
| 86 | for (int i = 0; i < 1000; ++i) |
| 87 | for (int j = 0; j < 3000; ++j) |
| 88 | std::copy(data.begin(), data.begin() + j, l.begin()); |
| 89 | stop_counters(time, resource); |
| 90 | report_performance(__FILE__, "deque 2 list", time, resource); |
| 91 | clear_counters(time, resource); |
| 92 | |
| 93 | d.assign(3000, 1); |
| 94 | |
| 95 | std::list<int>::iterator lit; |
| 96 | start_counters(time, resource); |
| 97 | for (int i = 0; i < 200; ++i) |
| 98 | { |
| 99 | lit = l.begin(); |
| 100 | for (int j = 0; j < 3000; ++j, ++lit) |
| 101 | std::copy(l.begin(), lit, d.begin()); |
| 102 | } |
| 103 | stop_counters(time, resource); |
| 104 | report_performance(__FILE__, "list 2 deque", time, resource); |
| 105 | |
| 106 | return 0; |
| 107 | } |