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>
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
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
35 for (test_type count = step; count <= max_size; count += step)
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);
47 #define thread_type false
51 #define thread_type true
54 typedef __gnu_test::sets<int, thread_type>::type container_types;
55 typedef test_sequence<thread_type> test_type;
56 test_type test("create_from_sorted");
57 __gnu_cxx::typelist::apply(test, container_types());