]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc
1 // Copyright (C) 2003-2013 Free Software Foundation, Inc.
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)
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.
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/>.
19 #include <testsuite_performance.h>
21 template<typename Container
, int Iter
>
26 const int iter
= 150000;
27 typedef Container container_type
;
32 for (int i
= 0; i
< iter
; ++i
)
33 obj
.push_back(rand()%500001);
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);
41 //Search for random values that may or may not belong to the list.
42 for (int i
= 0; i
< 50; ++i
)
44 typedef typename
container_type::iterator iterator_type
;
45 iterator_type _liter
= std::find(obj
.begin(), obj
.end(),
47 if (_liter
!= obj
.end())
58 #define thread_type false
62 #define thread_type true
65 typedef __gnu_test::lists
<int, thread_type
>::type container_types
;
66 typedef test_sequence
<thread_type
> test_type
;
67 test_type
test("sort_search");
68 __gnu_cxx::typelist::apply(test
, container_types());