]>
Commit | Line | Data |
---|---|---|
8d9254fc | 1 | // Copyright (C) 2019-2020 Free Software Foundation, Inc. |
6004c17b FD |
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 | ||
21 | #include <testsuite_performance.h> | |
22 | ||
23 | int main() | |
24 | { | |
25 | using namespace __gnu_test; | |
26 | ||
27 | time_counter time; | |
28 | resource_counter resource; | |
29 | ||
30 | const std::deque<int> data(3000, 1); | |
31 | ||
32 | std::deque<int> d(3000, 1); | |
33 | ||
34 | start_counters(time, resource); | |
35 | for (int i = 0; i < 1000; ++i) | |
36 | for (int j = 0; j < 3000; ++j) | |
37 | std::equal(data.begin(), data.begin() + j, d.begin()); | |
38 | stop_counters(time, resource); | |
39 | report_performance(__FILE__, "deque vs deque", time, resource); | |
40 | clear_counters(time, resource); | |
41 | ||
42 | std::vector<int> v(3000, 1); | |
43 | ||
44 | start_counters(time, resource); | |
45 | for (int i = 0; i < 1000; ++i) | |
46 | for (int j = 0; j < 3000; ++j) | |
47 | std::equal(data.begin(), data.begin() + j, v.begin()); | |
48 | stop_counters(time, resource); | |
49 | report_performance(__FILE__, "deque vs vector", time, resource); | |
50 | clear_counters(time, resource); | |
51 | ||
52 | d.assign(3000, 1); | |
53 | ||
54 | start_counters(time, resource); | |
55 | for (int i = 0; i < 1000; ++i) | |
56 | for (int j = 0; j < 3000; ++j) | |
57 | std::equal(v.begin(), v.begin() + j, d.begin()); | |
58 | stop_counters(time, resource); | |
59 | report_performance(__FILE__, "vector vs deque", time, resource); | |
60 | clear_counters(time, resource); | |
61 | ||
62 | std::vector<char> cv(3000, 1); | |
63 | ||
64 | start_counters(time, resource); | |
65 | for (int i = 0; i < 1000; ++i) | |
66 | for (int j = 0; j < 3000; ++j) | |
67 | std::equal(data.begin(), data.begin() + j, cv.begin()); | |
68 | stop_counters(time, resource); | |
69 | report_performance(__FILE__, "int deque vs char vector", time, resource); | |
70 | clear_counters(time, resource); | |
71 | ||
72 | d.assign(3000, 1); | |
73 | ||
74 | start_counters(time, resource); | |
75 | for (int i = 0; i < 1000; ++i) | |
76 | for (int j = 0; j < 3000; ++j) | |
77 | std::equal(cv.begin(), cv.begin() + j, d.begin()); | |
78 | stop_counters(time, resource); | |
79 | report_performance(__FILE__, "char vector vs int deque", time, resource); | |
80 | ||
81 | return 0; | |
82 | } |