]>
Commit | Line | Data |
---|---|---|
748086b7 | 1 | // Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. |
ac317859 PC |
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 | |
748086b7 | 6 | // Free Software Foundation; either version 3, or (at your option) |
ac317859 PC |
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 | |
748086b7 JJ |
15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
ac317859 | 17 | |
ac317859 | 18 | |
1d3d8fff | 19 | #include <testsuite_performance.h> |
ac317859 | 20 | |
fd1e1726 BK |
21 | template<typename Container, int Iter> |
22 | void | |
23 | do_loop() | |
24 | { | |
25 | // XXX | |
26 | const int iter = 150000; | |
27 | typedef Container container_type; | |
28 | container_type obj; | |
29 | int ctr = 3; | |
30 | while (ctr--) | |
31 | { | |
32 | for (int i = 0; i < iter; ++i) | |
33 | obj.push_back(rand()%500001); | |
ac317859 | 34 | |
fd1e1726 BK |
35 | //Search for random values that may or may not belong to the list. |
36 | for (int i = 0; i < 50; ++i) | |
37 | std::find(obj.begin(), obj.end(), rand() % 100001); | |
38 | ||
39 | obj.sort(); | |
40 | ||
41 | //Search for random values that may or may not belong to the list. | |
42 | for (int i = 0; i < 50; ++i) | |
43 | { | |
44 | typedef typename container_type::iterator iterator_type; | |
45 | iterator_type _liter = std::find(obj.begin(), obj.end(), | |
46 | rand() % 100001); | |
47 | if (_liter != obj.end()) | |
48 | obj.erase(_liter); | |
49 | } | |
50 | obj.clear(); | |
51 | } | |
52 | } | |
ac317859 | 53 | |
fd1e1726 BK |
54 | int |
55 | main() | |
56 | { | |
57 | #ifdef TEST_S1 | |
58 | #define thread_type false | |
59 | #endif | |
ac317859 | 60 | |
fd1e1726 BK |
61 | #ifdef TEST_T1 |
62 | #define thread_type true | |
63 | #endif | |
ac317859 | 64 | |
fd1e1726 | 65 | typedef __gnu_test::lists<int, thread_type>::type container_types; |
fd1e1726 BK |
66 | typedef test_sequence<thread_type> test_type; |
67 | test_type test("sort_search"); | |
d7f245b1 | 68 | __gnu_cxx::typelist::apply(test, container_types()); |
ac317859 | 69 | |
fd1e1726 | 70 | return 0; |
ac317859 | 71 | } |
fd1e1726 | 72 |