summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/performance/23_containers
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/performance/23_containers')
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc38
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/create/map.cc51
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc61
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc54
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/find/map.cc57
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/index/map.cc59
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc63
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc59
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc52
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc66
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc77
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc248
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc247
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc43
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc44
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc43
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc43
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc40
-rw-r--r--libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc72
19 files changed, 1417 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc b/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc
new file mode 100644
index 000000000..96e13ba33
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ start_counters(time, resource);
+ const std::vector<bool> ref(100000);
+
+ for (unsigned i = 0; i < 1000000; ++i)
+ std::vector<bool> v(ref);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/create/map.cc b/libstdc++-v3/testsuite/performance/23_containers/create/map.cc
new file mode 100644
index 000000000..4527f2c21
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/create/map.cc
@@ -0,0 +1,51 @@
+// 2003-03-01 gp dot bolton at computer dot org
+
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ Container obj;
+ const int iterations = 250000;
+ for (int i = 0; i < iterations; ++i)
+ obj[i] = i;
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::maps<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("create");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc b/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc
new file mode 100644
index 000000000..60911ca17
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ typedef int test_type;
+ typedef Container container_type;
+ static const unsigned max_size = 250000; // avoid excessive swap file use!
+ static const unsigned iterations = 10; // make results less random while
+ static const unsigned step = 50000; // keeping the total time reasonable
+
+ std::vector<test_type> v(max_size, 0);
+ for (test_type i = 0; i != max_size; ++i)
+ v[i] = i; // initialize sorted array
+
+ for (test_type count = step; count <= max_size; count += step)
+ {
+ // Measure set construction time (linear in count (Table 69))
+ for (test_type i = 0; i != iterations; ++i)
+ container_type(v.begin(), v.begin() + count);
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::sets<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("create_from_sorted");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc b/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc
new file mode 100644
index 000000000..d8b3b51bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc
@@ -0,0 +1,54 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ typedef Container container_type;
+ container_type obj;
+ const int iterations = 1000000;
+ for (unsigned int n = 1; n <= iterations; n *= 10)
+ {
+ for (unsigned int i = 0; i < n; ++i)
+ obj.push_back(n - i);
+ }
+ obj.sort();
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::lists<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("create_sort");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/find/map.cc b/libstdc++-v3/testsuite/performance/23_containers/find/map.cc
new file mode 100644
index 000000000..f206c2534
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/find/map.cc
@@ -0,0 +1,57 @@
+// Copyright (C) 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// 2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com>
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ Container obj;
+ int x = 2;
+ while (x--)
+ {
+ for (int i = 0; i < 300000; ++i)
+ obj.insert(std::make_pair(rand()%1000000, i));
+ for (int i = 0; i < 100000; ++i)
+ obj.insert(std::make_pair(rand()%2000000, i));
+ obj.clear();
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::maps<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("find");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/index/map.cc b/libstdc++-v3/testsuite/performance/23_containers/index/map.cc
new file mode 100644
index 000000000..0dad47523
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/index/map.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+// libstdc++/13823 recast for this testing framework
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ try
+ {
+ Container obj;
+ for (int c = 0; c < 100; c++)
+ {
+ for (unsigned i = 0; i < Iter; ++i)
+ obj[i] = i;
+ }
+ }
+ catch(...)
+ {
+ // No point allocating all available memory, repeatedly.
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::maps<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("index_associative");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc b/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc
new file mode 100644
index 000000000..c1ecc7f5f
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc
@@ -0,0 +1,63 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ Container obj; // XXX
+ int insert_values = 128; // XXX
+
+ int test_iterations = 0;
+
+ // XXX
+ // typedef typename Container::value_type test_type;
+ typedef int test_type;
+
+ value_type<test_type> test_value;
+ while (test_iterations < Iter)
+ {
+ for (int j = 0; j < insert_values; ++j)
+ obj.insert(++test_value);
+ ++test_iterations;
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ using __gnu_test::associative_containers;
+ typedef associative_containers<int, thread_type>::type container_types;
+
+ typedef test_sequence<thread_type> test_type;
+ test_type test("insert_associative");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc b/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc
new file mode 100644
index 000000000..9673992a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ Container obj; // XXX
+ int insert_values = 128; // XXX
+
+ int test_iterations = 0;
+ typedef typename Container::value_type test_type;
+ value_type<test_type> test_value;
+ while (test_iterations < Iter)
+ {
+ for (int j = 0; j < insert_values; ++j)
+ obj.insert(obj.end(), ++test_value);
+ ++test_iterations;
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ using __gnu_test::sequence_containers;
+ typedef sequence_containers<int, thread_type>::type container_types;
+
+ typedef test_sequence<thread_type> test_type;
+ test_type test("insert_sequence");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc b/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc
new file mode 100644
index 000000000..2cc22d1d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <tr1/unordered_map>
+#include <testsuite_performance.h>
+
+typedef std::tr1::unordered_map<int, int> map_type;
+typedef std::tr1::unordered_map<int, map_type> matrix_type;
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int sz = 1000;
+
+ matrix_type matrix;
+
+ start_counters(time, resource);
+ for (int iter = 0; iter < 50; ++iter)
+ {
+ for (int i = 0; i < sz; ++i)
+ {
+ for (int j = 0; j < sz; ++j)
+ {
+ map_type& row = matrix[i / 4];
+ ++row[j / 4];
+ }
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc b/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc
new file mode 100644
index 000000000..a310f8ed6
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc
@@ -0,0 +1,66 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ // XXX
+ // typedef typename Container::value_type test_type;
+ typedef int test_type;
+ value_type<test_type> test_value;
+
+ const int insert_values = 128; // XXX
+ Container obj; // XXX
+ for (int i = 0; i < Iter; ++i)
+ {
+ for (int j = 0; j < insert_values; ++j)
+ obj.insert(++test_value);
+ }
+
+ const int erasei = static_cast<int>(Iter / 4);
+ for (int i = 0; i < erasei; ++i)
+ {
+ int key = i * 2;
+ obj.erase(key);
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ using __gnu_test::associative_containers;
+ typedef associative_containers<int, thread_type>::type container_types;
+
+ typedef test_sequence<thread_type> test_type;
+ test_type test("insert_erase_associative");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc b/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc
new file mode 100644
index 000000000..2e94dcac7
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc
@@ -0,0 +1,77 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ // avoid excessive swap file use!
+ static const unsigned max_size = 250000;
+
+ // make results less random while
+ static const unsigned iterations = 10;
+
+ // keeping the total time reasonable
+ static const unsigned step = 50000;
+
+ using namespace std;
+ typedef int test_type;
+ typedef Container container_type;
+ typedef vector<test_type> vector_type;
+
+ // Initialize sorted array.
+ vector_type v(max_size, 0);
+ for (unsigned int i = 0; i != max_size; ++i)
+ v[i] = i;
+
+ for (unsigned int count = step; count <= max_size; count += step)
+ {
+ for (unsigned i = 0; i != iterations; ++i)
+ {
+ container_type test_set;
+ typename container_type::iterator iter = test_set.end();
+
+ // Each insert in amortized constant time (Table 69)
+ for (unsigned j = 0; j != count; ++j)
+ iter = test_set.insert(iter, v[j]);
+ }
+ }
+
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::sets<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("insert_from_sorted");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc
new file mode 100644
index 000000000..0db964e59
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc
@@ -0,0 +1,248 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+typedef int test_type;
+
+// The number of iterations to be performed.
+int iterations = 1000;
+
+// TODO - restore Stefan's comment? i don't understand it. -- fwy
+int insert_values = 128;
+
+class Lock
+{
+public:
+ Lock() {pthread_mutex_init(&mutex, 0);}
+ ~Lock() {pthread_mutex_destroy(&mutex);}
+
+public:
+ inline pthread_mutex_t* operator&() {return &mutex;}
+
+public:
+ inline void lock() {pthread_mutex_lock(&mutex);}
+ inline void unlock() {pthread_mutex_unlock(&mutex);}
+
+private:
+ Lock(const Lock&);
+ Lock& operator=(Lock&);
+
+private:
+ pthread_mutex_t mutex;
+};
+
+class AutoLock
+{
+public:
+ AutoLock(Lock& _lock)
+ : lock(_lock)
+ {lock.lock();}
+
+ ~AutoLock() {lock.unlock();}
+
+private:
+ AutoLock(AutoLock&);
+ AutoLock& operator=(AutoLock&);
+
+private:
+ Lock& lock;
+};
+
+template<typename Container>
+ class Queue
+ {
+ public:
+ Queue() {pthread_cond_init(&condition, 0);}
+ ~Queue() {pthread_cond_destroy(&condition);}
+
+ public:
+ void push_back(const typename Container::value_type& x);
+ void swap(Container& container);
+
+ private:
+ pthread_cond_t condition;
+ Lock lock;
+ Container queue;
+ };
+
+template<typename Container>
+ void
+ Queue<Container>::push_back(const typename Container::value_type& value)
+ {
+ AutoLock auto_lock(lock);
+ const bool signal = queue.empty();
+ queue.insert(queue.end(), value);
+ if (signal) pthread_cond_signal(&condition);
+ }
+
+template<typename Container>
+ void
+ Queue<Container>::swap(Container& container)
+ {
+ AutoLock auto_lock(lock);
+ while (queue.empty()) pthread_cond_wait(&condition, &lock);
+ queue.swap(container);
+ }
+
+class Thread
+{
+ // NB: Make this the last data member of an object defining operator()().
+public:
+ class Attributes
+ {
+ public:
+ Attributes(int state = PTHREAD_CREATE_JOINABLE);
+ ~Attributes() {pthread_attr_destroy(&attributes);}
+
+ public:
+ inline pthread_attr_t* operator&() {return &attributes;}
+
+ private:
+ pthread_attr_t attributes;
+ };
+
+public:
+ Thread() {thread = pthread_self();}
+ ~Thread();
+
+public:
+ template <typename ThreadOwner>
+ void create(ThreadOwner* owner);
+
+private:
+ pthread_t thread;
+};
+
+Thread::Attributes::Attributes(int state)
+{
+ pthread_attr_init(&attributes);
+ pthread_attr_setdetachstate(&attributes, state);
+}
+
+Thread::~Thread()
+{
+ if (!pthread_equal(thread, pthread_self()))
+ pthread_join(thread, 0);
+}
+
+template<typename ThreadOwner>
+ void*
+ create_thread(void* _this)
+ {
+ ThreadOwner* owner = static_cast<ThreadOwner*>(_this);
+ (*owner)();
+ return 0;
+ }
+
+template<typename ThreadOwner>
+ void
+ Thread::create(ThreadOwner* owner)
+ {
+ Thread::Attributes attributes;
+ pthread_create(&thread, &attributes, create_thread<ThreadOwner>, owner);
+ }
+
+template<typename Container>
+ class Consumer
+ {
+ public:
+ Consumer(Queue<Container>& _queue)
+ : queue(_queue)
+ {thread.create(this);}
+
+ public:
+ void operator()();
+
+ private:
+ Queue<Container>& queue;
+ Thread thread;
+ };
+
+template<typename Container>
+ void
+ Consumer<Container>::operator()()
+ {
+ for (int j = insert_values * iterations; j > 0;)
+ {
+ Container container;
+ queue.swap(container);
+ j -= container.size();
+ }
+ }
+
+template<typename TestType>
+ struct Value : public std::pair<TestType, TestType>
+ {
+ Value()
+ : std::pair<TestType, TestType>(0, 0)
+ { }
+
+ inline Value operator++() {return ++this->first, *this;}
+ inline operator TestType() const {return this->first;}
+ };
+
+template<typename Container>
+ class ProducerConsumer : private Queue<Container>
+ {
+ public:
+ ProducerConsumer() {thread.create(this);}
+
+ public:
+ void operator()();
+
+ private:
+ Thread thread;
+ };
+
+template<typename Container>
+ void
+ ProducerConsumer<Container>::operator()()
+ {
+ Consumer<Container> consumer(*this);
+ Value<test_type> test_value;
+ for (int j = insert_values * iterations; j-- > 0;)
+ this->push_back(++test_value);
+ }
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ ProducerConsumer<Container> pc1;
+ ProducerConsumer<Container> pc2;
+ }
+
+int
+main()
+{
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::maps<test_type, thread_type>::type map_typelist;
+ typedef __gnu_test::sets<test_type, thread_type>::type set_typelist;
+ typedef __gnu_cxx::typelist::append<map_typelist, set_typelist>::type container_types;
+
+ typedef test_sequence<thread_type> test_type;
+ test_type test("producer_consumer_associative");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc
new file mode 100644
index 000000000..19118c952
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc
@@ -0,0 +1,247 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+typedef int test_type;
+
+// The number of iterations to be performed.
+int iterations = 1000;
+
+// TODO - restore Stefan's comment? i don't understand it. -- fwy
+int insert_values = 128;
+
+class Lock
+{
+public:
+ Lock() {pthread_mutex_init(&mutex, 0);}
+ ~Lock() {pthread_mutex_destroy(&mutex);}
+
+public:
+ inline pthread_mutex_t* operator&() {return &mutex;}
+
+public:
+ inline void lock() {pthread_mutex_lock(&mutex);}
+ inline void unlock() {pthread_mutex_unlock(&mutex);}
+
+private:
+ Lock(const Lock&);
+ Lock& operator=(Lock&);
+
+private:
+ pthread_mutex_t mutex;
+};
+
+class AutoLock
+{
+public:
+ AutoLock(Lock& _lock)
+ : lock(_lock)
+ {lock.lock();}
+
+ ~AutoLock() {lock.unlock();}
+
+private:
+ AutoLock(AutoLock&);
+ AutoLock& operator=(AutoLock&);
+
+private:
+ Lock& lock;
+};
+
+template<typename Container>
+ class Queue
+ {
+ public:
+ Queue() {pthread_cond_init(&condition, 0);}
+ ~Queue() {pthread_cond_destroy(&condition);}
+
+ public:
+ void push_back(const typename Container::value_type& x);
+ void swap(Container& container);
+
+ private:
+ pthread_cond_t condition;
+ Lock lock;
+ Container queue;
+ };
+
+template<typename Container>
+ void
+ Queue<Container>::push_back(const typename Container::value_type& value)
+ {
+ AutoLock auto_lock(lock);
+ const bool signal = queue.empty();
+ queue.insert(queue.end(), value);
+ if (signal) pthread_cond_signal(&condition);
+ }
+
+template<typename Container>
+ void
+ Queue<Container>::swap(Container& container)
+ {
+ AutoLock auto_lock(lock);
+ while (queue.empty()) pthread_cond_wait(&condition, &lock);
+ queue.swap(container);
+ }
+
+class Thread
+{
+ // NB: Make this the last data member of an object defining operator()().
+public:
+ class Attributes
+ {
+ public:
+ Attributes(int state = PTHREAD_CREATE_JOINABLE);
+ ~Attributes() {pthread_attr_destroy(&attributes);}
+
+ public:
+ inline pthread_attr_t* operator&() {return &attributes;}
+
+ private:
+ pthread_attr_t attributes;
+ };
+
+public:
+ Thread() {thread = pthread_self();}
+ ~Thread();
+
+public:
+ template <typename ThreadOwner>
+ void create(ThreadOwner* owner);
+
+private:
+ pthread_t thread;
+};
+
+Thread::Attributes::Attributes(int state)
+{
+ pthread_attr_init(&attributes);
+ pthread_attr_setdetachstate(&attributes, state);
+}
+
+Thread::~Thread()
+{
+ if (!pthread_equal(thread, pthread_self()))
+ pthread_join(thread, 0);
+}
+
+template<typename ThreadOwner>
+ void*
+ create_thread(void* _this)
+ {
+ ThreadOwner* owner = static_cast<ThreadOwner*>(_this);
+ (*owner)();
+ return 0;
+ }
+
+template<typename ThreadOwner>
+ void
+ Thread::create(ThreadOwner* owner)
+ {
+ Thread::Attributes attributes;
+ pthread_create(&thread, &attributes, create_thread<ThreadOwner>, owner);
+ }
+
+template<typename Container>
+ class Consumer
+ {
+ public:
+ Consumer(Queue<Container>& _queue)
+ : queue(_queue)
+ {thread.create(this);}
+
+ public:
+ void operator()();
+
+ private:
+ Queue<Container>& queue;
+ Thread thread;
+ };
+
+template<typename Container>
+ void
+ Consumer<Container>::operator()()
+ {
+ for (int j = insert_values * iterations; j > 0;)
+ {
+ Container container;
+ queue.swap(container);
+ j -= container.size();
+ }
+ }
+
+template<typename TestType>
+ struct Value : public std::pair<TestType, TestType>
+ {
+ Value()
+ : std::pair<TestType, TestType>(0, 0)
+ { }
+
+ inline Value operator++() {return ++this->first, *this;}
+ inline operator TestType() const {return this->first;}
+ };
+
+template<typename Container>
+ class ProducerConsumer : private Queue<Container>
+ {
+ public:
+ ProducerConsumer() {thread.create(this);}
+
+ public:
+ void operator()();
+
+ private:
+ Thread thread;
+ };
+
+template<typename Container>
+ void
+ ProducerConsumer<Container>::operator()()
+ {
+ Consumer<Container> consumer(*this);
+ Value<test_type> test_value;
+ for (int j = insert_values * iterations; j-- > 0;)
+ this->push_back(++test_value);
+ }
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ ProducerConsumer<Container> pc1;
+ ProducerConsumer<Container> pc2;
+ }
+
+int
+main()
+{
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ using __gnu_test::sequence_containers;
+ typedef sequence_containers<test_type, thread_type>::type container_types;
+
+ typedef test_sequence<thread_type> test_type;
+ test_type test("producer_consumer_sequence");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc b/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc
new file mode 100644
index 000000000..c8a804ed2
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// Performance test of debug mode deque range constructor
+#define _GLIBCXX_DEBUG
+
+#include <deque>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const std::deque<int> ref(50000, 3);
+
+ start_counters(time, resource);
+
+ for (unsigned i = 0; i < 1000; ++i)
+ std::deque<int> v(ref.begin(), ref.end());
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc b/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc
new file mode 100644
index 000000000..19224ad2f
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// Performance test of debug mode list range constructor
+#define _GLIBCXX_DEBUG
+
+#include <vector>
+#include <list>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const std::vector<int> ref(50000, 3);
+
+ start_counters(time, resource);
+
+ for (unsigned i = 0; i < 1000; ++i)
+ std::list<int> l(ref.begin(), ref.end());
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc b/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc
new file mode 100644
index 000000000..51bc7a17b
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// Performance test of debug mode list range constructor
+#define _GLIBCXX_DEBUG
+
+#include <list>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const std::list<int> ref(50000, 3);
+
+ start_counters(time, resource);
+
+ for (unsigned i = 0; i < 1000; ++i)
+ std::list<int> l(ref.begin(), ref.end());
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc b/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc
new file mode 100644
index 000000000..08716a543
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// Performance test of debug mode vector range constructor
+#define _GLIBCXX_DEBUG
+
+#include <vector>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const std::vector<int> ref(50000, 3);
+
+ start_counters(time, resource);
+
+ for (unsigned i = 0; i < 1000; ++i)
+ std::vector<int> v(ref.begin(), ref.end());
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc b/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc
new file mode 100644
index 000000000..ac329a0ac
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <testsuite_performance.h>
+
+// libstdc++/28587
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ start_counters(time, resource);
+ for (unsigned i = 0; i < 200000; ++i)
+ {
+ std::vector<bool> vec;
+ vec.resize(i);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc b/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc
new file mode 100644
index 000000000..72c5ed977
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc
@@ -0,0 +1,72 @@
+// Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <testsuite_performance.h>
+
+template<typename Container, int Iter>
+ void
+ do_loop()
+ {
+ // XXX
+ const int iter = 150000;
+ typedef Container container_type;
+ container_type obj;
+ int ctr = 3;
+ while (ctr--)
+ {
+ for (int i = 0; i < iter; ++i)
+ obj.push_back(rand()%500001);
+
+ //Search for random values that may or may not belong to the list.
+ for (int i = 0; i < 50; ++i)
+ std::find(obj.begin(), obj.end(), rand() % 100001);
+
+ obj.sort();
+
+ //Search for random values that may or may not belong to the list.
+ for (int i = 0; i < 50; ++i)
+ {
+ typedef typename container_type::iterator iterator_type;
+ iterator_type _liter = std::find(obj.begin(), obj.end(),
+ rand() % 100001);
+ if (_liter != obj.end())
+ obj.erase(_liter);
+ }
+ obj.clear();
+ }
+ }
+
+int
+main()
+{
+#ifdef TEST_S1
+#define thread_type false
+#endif
+
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ typedef __gnu_test::lists<int, thread_type>::type container_types;
+ typedef test_sequence<thread_type> test_type;
+ test_type test("sort_search");
+ __gnu_cxx::typelist::apply(test, container_types());
+
+ return 0;
+}
+