]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2003-2023 Free Software Foundation, Inc. |
21c332dc 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) |
21c332dc 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/>. | |
21c332dc | 17 | |
21c332dc | 18 | |
1d3d8fff | 19 | #include <testsuite_performance.h> |
21c332dc | 20 | |
fd1e1726 BK |
21 | template<typename Container, int Iter> |
22 | void | |
23 | do_loop() | |
24 | { | |
25 | typedef int test_type; | |
26 | typedef Container container_type; | |
27 | static const unsigned max_size = 250000; // avoid excessive swap file use! | |
28 | static const unsigned iterations = 10; // make results less random while | |
29 | static const unsigned step = 50000; // keeping the total time reasonable | |
21c332dc | 30 | |
fd1e1726 BK |
31 | std::vector<test_type> v(max_size, 0); |
32 | for (test_type i = 0; i != max_size; ++i) | |
33 | v[i] = i; // initialize sorted array | |
34 | ||
35 | for (test_type count = step; count <= max_size; count += step) | |
36 | { | |
37 | // Measure set construction time (linear in count (Table 69)) | |
38 | for (test_type i = 0; i != iterations; ++i) | |
39 | container_type(v.begin(), v.begin() + count); | |
40 | } | |
41 | } | |
21c332dc | 42 | |
fd1e1726 BK |
43 | int |
44 | main() | |
45 | { | |
46 | #ifdef TEST_S1 | |
47 | #define thread_type false | |
48 | #endif | |
21c332dc | 49 | |
fd1e1726 BK |
50 | #ifdef TEST_T1 |
51 | #define thread_type true | |
52 | #endif | |
21c332dc | 53 | |
fd1e1726 | 54 | typedef __gnu_test::sets<int, thread_type>::type container_types; |
fd1e1726 BK |
55 | typedef test_sequence<thread_type> test_type; |
56 | test_type test("create_from_sorted"); | |
d7f245b1 | 57 | __gnu_cxx::typelist::apply(test, container_types()); |
fd1e1726 BK |
58 | |
59 | return 0; | |
21c332dc | 60 | } |
fd1e1726 | 61 |