1// Copyright (C) 2003-2015 Free Software Foundation, Inc. 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 19#include <testsuite_performance.h> 20 21template<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 30 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 } 42 43int 44main() 45{ 46#ifdef TEST_S1 47#define thread_type false 48#endif 49 50#ifdef TEST_T1 51#define thread_type true 52#endif 53 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()); 58 59 return 0; 60} 61 62