aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libstdc++-v3/testsuite/performance
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libstdc++-v3/testsuite/performance
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/performance')
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-1.cc77
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-2.cc46
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/cons_input_iterator.cc49
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/copy_cons_and_dest.cc52
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/find.cc96
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/hash.cc58
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/is_wchar_t.cc78
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_char.cc67
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_wchar_t.cc67
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_in.cc75
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_length.cc53
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_out.cc75
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/unordered_set.cc43
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc38
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create/map.cc51
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc61
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc54
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/find/map.cc57
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/index/map.cc59
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/54075.cc188
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc63
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc59
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc52
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_multiset_hint.cc336
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_set.cc53
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc216
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc66
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc77
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc248
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc247
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc43
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc44
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc43
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc43
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc40
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc72
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc40
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc40
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_streambuf_iterators.cc98
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/find_istreambuf_iterators.cc54
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/lexicographical_compare.cc46
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/nth_element_worst_case.cc53
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc63
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort.cc65
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort_heap.cc73
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/stable_sort.cc65
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/complex_norm.cc74
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/valarray_gslice_to_index.cc48
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/cout_insert_int.cc39
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_copy.cc66
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc85
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputc.cc65
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc73
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fmtflags_manipulators.cc60
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fstream_seek_write.cc49
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc82
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_float.cc67
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_int.cc48
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline-2.cc93
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline.cc52
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_float.cc59
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_int.cc41
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/27_io/stringbuf_overflow.cc51
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.cc45
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.h91
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split_bfs.cc46
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc64
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_find.cc126
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_find.cc126
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_insert.cc123
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc145
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_int_erase_mem.cc118
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_int_find.cc119
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp137
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_large.cc41
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_small.cc42
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp137
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_large.cc41
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp155
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_large.cc41
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_small.cc41
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_small.cc41
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push.cc116
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push_pop.cc118
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join.cc113
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp127
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_down.cc37
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_up.cc37
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc122
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push.cc117
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc116
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics.cc105
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join.cc107
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert.cc116
-rw-r--r--gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find.cc115
95 files changed, 7720 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-1.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-1.cc
new file mode 100644
index 000000000..5e4b91390
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-1.cc
@@ -0,0 +1,77 @@
+ // Copyright (C) 2003-2014 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 <ctime>
+#include <iostream>
+#include <string>
+#include <testsuite_performance.h>
+
+using namespace std;
+
+void
+test_append_char(int how_much)
+{
+ string buf; // no preallocation
+ for (int i = 0; i < how_much; ++i)
+ buf.append(static_cast<string::size_type>(1) , 'x');
+}
+
+void
+test_append_string(int how_much)
+{
+ string s(static_cast<string::size_type>(1) , 'x');
+ string buf; // no preallocation
+ for (int i = 0; i < how_much; ++i)
+ buf.append(s);
+}
+
+void
+run_benchmark1(int how_much)
+{
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+ start_counters(time, resource);
+ test_append_char(how_much);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "char", time, resource);
+}
+
+void
+run_benchmark2(int how_much)
+{
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+ start_counters(time, resource);
+ test_append_string(how_much);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "string", time, resource);
+}
+
+// libstdc++/5380
+// libstdc++/4960
+int main()
+{
+ run_benchmark1(100000);
+ run_benchmark2(100000);
+ run_benchmark1(1000000);
+ run_benchmark2(1000000);
+ run_benchmark1(10000000);
+ run_benchmark2(10000000);
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-2.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-2.cc
new file mode 100644
index 000000000..e04a7084f
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/append-2.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2004-2014 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 <string>
+#include <testsuite_performance.h>
+
+// Short strings didn't grow quickly...
+void test01()
+{
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+
+ start_counters(time, resource);
+ for (unsigned i = 0; i < 200000; ++i)
+ {
+ std::string a;
+ for (unsigned j = 0; j < 400; ++j)
+ a.append(1, 'x');
+ }
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "", time, resource);
+ clear_counters(time, resource);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/cons_input_iterator.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/cons_input_iterator.cc
new file mode 100644
index 000000000..729735ea5
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/cons_input_iterator.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2004-2014 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 <iterator>
+#include <sstream>
+
+#include <testsuite_performance.h>
+
+void benchmark(long len)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ istringstream isstr(string(len, 'a'));
+
+ start_counters(time, resource);
+ string str((istreambuf_iterator<char>(isstr)),
+ istreambuf_iterator<char>());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "", time, resource);
+ clear_counters(time, resource);
+}
+
+int main()
+{
+ benchmark(500000);
+ benchmark(5000000);
+ benchmark(50000000);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/copy_cons_and_dest.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/copy_cons_and_dest.cc
new file mode 100644
index 000000000..9fa89a55a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/copy_cons_and_dest.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2006-2014 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 <string>
+#include <testsuite_performance.h>
+
+void benchmark(long len)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ start_counters(time, resource);
+ string a("1");
+ for (long i = 0; i < len; ++i)
+ {
+ string ss1(a);
+ string ss2(ss1);
+ string ss3(ss2);
+ string ss4(ss3);
+ string ss5(ss4);
+ }
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "", time, resource);
+ clear_counters(time, resource);
+}
+
+int main()
+{
+ benchmark(1000000);
+ benchmark(10000000);
+ benchmark(100000000);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/find.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/find.cc
new file mode 100644
index 000000000..350a08354
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/find.cc
@@ -0,0 +1,96 @@
+ // Copyright (C) 2004-2014 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 <string>
+#include <testsuite_performance.h>
+
+void
+test_pair(const std::string& s, const std::string& f, int n)
+{
+ std::string::size_type sz = 0;
+
+ for (int i = 0; i < n; ++i)
+ sz = s.find(f);
+}
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const unsigned int iterations = 2000000;
+
+ string s, f;
+ s = "aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy";
+ f = "aabbaabbc";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "1", time, resource);
+ clear_counters(time, resource);
+
+ f = "aabbb";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "2", time, resource);
+ clear_counters(time, resource);
+
+ f = "xd";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "3", time, resource);
+ clear_counters(time, resource);
+
+ s = "dhruv is a very very good boy ;-)";
+ f = "very";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "4", time, resource);
+ clear_counters(time, resource);
+
+ f = "bad";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "5", time, resource);
+ clear_counters(time, resource);
+
+ f = "extra irritating";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "6", time, resource);
+ clear_counters(time, resource);
+
+ s = "this is a very this is a very this is a verty this is a very "
+ "this is a very long sentence";
+ f = "this is a very long sentence";
+ start_counters(time, resource);
+ test_pair(s, f, iterations);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "7", time, resource);
+ clear_counters(time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/hash.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/hash.cc
new file mode 100644
index 000000000..0c409c5da
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/21_strings/hash.cc
@@ -0,0 +1,58 @@
+#include <string>
+#include <vector>
+#include <unordered_set>
+#include <cstdlib>
+#include <random>
+#include <testsuite_performance.h>
+
+using namespace std;
+
+vector<string>
+random_strings(int n, int len)
+{
+ string s(len, '\0');
+ unordered_set<string> result_set;
+ random_device rd;
+ while (result_set.size() < n)
+ {
+ result_set.insert(s);
+ unsigned int tmp = rd();
+ tmp %= len * 256;
+ s[tmp / 256] = tmp % 256;
+ }
+ return vector<string>(result_set.begin(), result_set.end());
+}
+
+int
+main(int argc, char **argv)
+{
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+
+ int string_size = 71;
+ int num_strings = 6000000;
+ if (argc > 1)
+ {
+ string_size = atoi(argv[1]);
+ if (argc > 2)
+ num_strings = atoi(argv[2]);
+ }
+
+ // Construct random strings.
+ vector<string> v = random_strings(num_strings, string_size);
+
+ // Time hashing.
+ size_t tmp = 0; // prevent compiler from optimizing away all the work
+ start_counters(time, resource);
+ for (int i = 0; i < num_strings; i++)
+ tmp += hash<string>()(v[i]);
+ stop_counters(time, resource);
+
+ if (tmp != 0 || argc < 9) // use tmp to prevent compiler optimization
+ report_performance(__FILE__, "", time, resource);
+
+ clear_counters(time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/is_wchar_t.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/is_wchar_t.cc
new file mode 100644
index 000000000..d03269b22
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/is_wchar_t.cc
@@ -0,0 +1,78 @@
+// Copyright (C) 2003-2014 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 <locale>
+#include <cwctype>
+#include <cstddef>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const wchar_t str[] =
+ L"Is this the real life?\n"
+ L"Is this just fantasy?\n"
+ L"Caught in a landslide\n"
+ L"No escape from reality\n"
+ L"Open your eyes\n"
+ L"Look up to the skies and see\n"
+ L"I'm just a poor boy\n"
+ L"I need no sympathy\n"
+ L"Because I'm easy come, easy go\n"
+ L"Little high, little low"
+ L"Anyway the wind blows\n"
+ L"Doesn't really matter to me\n"
+ L"To me\n"
+ L" -- Queen\n";
+ const size_t len = sizeof(str) / sizeof(str[0]) - 1;
+
+ locale loc;
+ const ctype<wchar_t>& ct = use_facet<ctype<wchar_t> >(loc);
+
+ // C
+ wctype_t w = wctype("space");
+ start_counters(time, resource);
+ for (int j = 0; j < 200000; ++j)
+ {
+ for (size_t i = 0; i < len; ++i)
+ {
+ iswctype(str[i], w);
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C", time, resource);
+ clear_counters(time, resource);
+
+ // C++
+ start_counters(time, resource);
+ for (int j = 0; j < 200000; ++j)
+ {
+ for (size_t i = 0; i < len; ++i)
+ {
+ ct.is(ctype_base::space, str[i]);
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_char.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_char.cc
new file mode 100644
index 000000000..70cf06a6f
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_char.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2003-2014 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 <locale>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ char bufin[] = "This was an attempt to bypass string construction just for test.";
+ char bufout[sizeof(bufin)];
+
+ locale loc;
+ const ctype<char>& ct = use_facet<ctype<char> >(loc);
+
+ // narrow
+ start_counters(time, resource);
+ for (long i = 0; i < 1000000000; ++i)
+ ct.narrow(i % 128, '*');
+ stop_counters(time, resource);
+ report_performance(__FILE__, "narrow", time, resource);
+ clear_counters(time, resource);
+
+ // narrow array
+ start_counters(time, resource);
+ for (long i = 0; i < 100000000; ++i)
+ ct.narrow(bufin, bufin+sizeof(bufin), '*', bufout);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "narrow_array", time, resource);
+ clear_counters(time, resource);
+
+ // widen
+ start_counters(time, resource);
+ for (long i = 0; i < 1000000000; ++i)
+ ct.widen(i % 128);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "widen", time, resource);
+ clear_counters(time, resource);
+
+ // widen array
+ start_counters(time, resource);
+ for (long i = 0; i < 100000000; ++i)
+ ct.widen(bufin, bufin+sizeof(bufin), bufout);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "widen_array", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_wchar_t.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_wchar_t.cc
new file mode 100644
index 000000000..82d59228b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/narrow_widen_wchar_t.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2003-2014 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 <locale>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ wchar_t bufwc[] = L"Mi innamoravo di tutto (Fabrizio De Andre')";
+ char bufc[sizeof(bufwc) / sizeof(wchar_t)];
+
+ locale loc;
+ const ctype<wchar_t>& ct = use_facet<ctype<wchar_t> >(loc);
+
+ // narrow
+ start_counters(time, resource);
+ for (long i = 0; i < 200000000; ++i)
+ ct.narrow(i % 128, '*');
+ stop_counters(time, resource);
+ report_performance(__FILE__, "narrow", time, resource);
+ clear_counters(time, resource);
+
+ // narrow array
+ start_counters(time, resource);
+ for (long i = 0; i < 20000000; ++i)
+ ct.narrow(bufwc, bufwc + sizeof(bufwc) / sizeof(wchar_t), '*', bufc);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "narrow array", time, resource);
+ clear_counters(time, resource);
+
+ // widen
+ start_counters(time, resource);
+ for (long i = 0; i < 200000000; ++i)
+ ct.widen(i % 128);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "widen", time, resource);
+ clear_counters(time, resource);
+
+ // widen array
+ start_counters(time, resource);
+ for (long i = 0; i < 20000000; ++i)
+ ct.widen(bufc, bufc + sizeof(bufc), bufwc);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "widen array", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_in.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_in.cc
new file mode 100644
index 000000000..6e0921bf8
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_in.cc
@@ -0,0 +1,75 @@
+// Copyright (C) 2003-2014 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 <cstdio>
+#include <cstring>
+#include <fstream>
+#include <langinfo.h>
+#include <iconv.h>
+#include <testsuite_performance.h>
+
+// libstdc++/11602 (do_in)
+int main(int argc, char** argv)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iters = 400000;
+
+ wchar_t wbuf[1024];
+ char cbuf[1024];
+
+ memset(cbuf, 'a', 1024);
+
+ // C (iconv)
+ iconv_t cd = iconv_open("WCHAR_T", nl_langinfo(CODESET));
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ {
+ size_t inbytesleft = 1024;
+ size_t outbytesleft = 1024 * sizeof(wchar_t);
+ char* in = cbuf;
+ char* out = reinterpret_cast<char*>(wbuf);
+ iconv(cd, &in, &inbytesleft, &out, &outbytesleft);
+ }
+ stop_counters(time, resource);
+ iconv_close(cd);
+ report_performance(__FILE__, "C (iconv)", time, resource);
+ clear_counters(time, resource);
+
+ // C++ (codecvt)
+ locale loc;
+ const codecvt<wchar_t, char, mbstate_t>& cvt =
+ use_facet<codecvt<wchar_t, char, mbstate_t> >(loc);
+ mbstate_t state;
+ memset(&state, 0, sizeof(state));
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ {
+ const char* from_next;
+ wchar_t* to_next;
+ cvt.in(state, cbuf, cbuf + 1024, from_next,
+ wbuf, wbuf + 1024, to_next);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++ (codecvt)", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_length.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_length.cc
new file mode 100644
index 000000000..81f994fc6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_length.cc
@@ -0,0 +1,53 @@
+// Copyright (C) 2003-2014 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 <cstdio>
+#include <cstring>
+#include <fstream>
+#include <langinfo.h>
+#include <iconv.h>
+#include <testsuite_performance.h>
+
+// libstdc++/11602 (do_length)
+int main(int argc, char** argv)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iters = 400000;
+
+ char cbuf[1024];
+
+ memset(cbuf, 'a', 1024);
+
+ // C++ (codecvt)
+ locale loc;
+ const codecvt<wchar_t, char, mbstate_t>& cvt =
+ use_facet<codecvt<wchar_t, char, mbstate_t> >(loc);
+ mbstate_t state;
+ memset(&state, 0, sizeof(state));
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ cvt.length(state, cbuf, cbuf + 1024, 1024);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++ (codecvt)", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_out.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_out.cc
new file mode 100644
index 000000000..cc2c8845f
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/22_locale/wchar_t_out.cc
@@ -0,0 +1,75 @@
+// Copyright (C) 2003-2014 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 <cstdio>
+#include <cstring>
+#include <fstream>
+#include <langinfo.h>
+#include <iconv.h>
+#include <testsuite_performance.h>
+
+// libstdc++/11602
+int main(int argc, char** argv)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iters = 300000;
+
+ wchar_t wbuf[1024];
+ char cbuf[1024];
+
+ wmemset(wbuf, L'a', 1024);
+
+ // C (iconv)
+ iconv_t cd = iconv_open(nl_langinfo(CODESET), "WCHAR_T");
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ {
+ size_t inbytesleft = 1024 * sizeof(wchar_t);
+ size_t outbytesleft = 1024;
+ char* in = reinterpret_cast<char*>(wbuf);
+ char* out = cbuf;
+ iconv(cd, &in, &inbytesleft, &out, &outbytesleft);
+ }
+ stop_counters(time, resource);
+ iconv_close(cd);
+ report_performance(__FILE__, "C (iconv)", time, resource);
+ clear_counters(time, resource);
+
+ // C++ (codecvt)
+ locale loc;
+ const codecvt<wchar_t, char, mbstate_t>& cvt =
+ use_facet<codecvt<wchar_t, char, mbstate_t> >(loc);
+ mbstate_t state;
+ memset(&state, 0, sizeof(state));
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ {
+ const wchar_t* from_next;
+ char* to_next;
+ cvt.out(state, wbuf, wbuf + 1024, from_next,
+ cbuf, cbuf + 1024, to_next);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++ (codecvt)", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/unordered_set.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/unordered_set.cc
new file mode 100644
index 000000000..3ca2d5fef
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/unordered_set.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+// Copyright (C) 2011-2014 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 <unordered_set>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ std::unordered_set<int> ref;
+ for (int i = 0; i != 500000; ++i)
+ ref.insert(i);
+
+ start_counters(time, resource);
+
+ for (unsigned i = 0; i < 500; ++i)
+ std::unordered_set<int> v(ref);
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "unordered_set<int> copy", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc
new file mode 100644
index 000000000..85679cc96
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2006-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create/map.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create/map.cc
new file mode 100644
index 000000000..a15014f8f
--- /dev/null
+++ b/gcc-4.9/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-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc
new file mode 100644
index 000000000..0804b940a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc
new file mode 100644
index 000000000..900e20b93
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc
@@ -0,0 +1,54 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/find/map.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/find/map.cc
new file mode 100644
index 000000000..ed1cf7361
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/find/map.cc
@@ -0,0 +1,57 @@
+// Copyright (C) 2004-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/index/map.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/index/map.cc
new file mode 100644
index 000000000..0bd1044f6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/index/map.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/54075.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/54075.cc
new file mode 100644
index 000000000..4703e48be
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/54075.cc
@@ -0,0 +1,188 @@
+// Copyright (C) 2012-2014 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/>.
+
+// { dg-options "-std=c++11" }
+
+#include <testsuite_performance.h>
+#include <random>
+#include <sstream>
+#include <tr1/unordered_set>
+#include <unordered_set>
+
+#define USE_MY_FOO 1
+
+struct Foo
+{
+#if USE_MY_FOO
+
+ typedef std::random_device::result_type _Type;
+ _Type bar;
+ _Type baz;
+ _Type meh;
+
+ void
+ init(std::random_device& randev)
+ {
+ bar = randev();
+ baz = randev();
+ meh = randev();
+ }
+
+#else
+
+ int bar;
+ int baz;
+ int meh;
+
+ Foo()
+ { bar = random(); baz = random(); meh = random(); }
+ Foo(const Foo&) = default;
+
+#endif
+
+ std::size_t
+ hash() const noexcept
+ { return std::size_t(bar ^ baz ^ meh); }
+
+ inline bool
+ operator==(const Foo& other) const
+ { return other.bar == bar && other.baz == baz && other.meh == meh; }
+};
+
+struct HashFunction
+{
+ template<typename T>
+ std::size_t operator()(const T& t) const noexcept
+ { return t.hash(); }
+};
+
+const int sz = 300000;
+
+template<typename _ContType>
+ void
+ bench(const char* container_desc, const typename _ContType::value_type* foos)
+ {
+ using namespace __gnu_test;
+
+ _ContType s;
+
+ time_counter time;
+ resource_counter resource;
+ start_counters(time, resource);
+
+ for (int i = 0; i != sz ; ++i)
+ s.insert(foos[i]);
+
+ stop_counters(time, resource);
+ std::ostringstream ostr;
+ ostr << container_desc << sz << " insertion attempts, "
+ << s.size() << " inserted";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ // Try to insert again to check performance of collision detection
+ const int nb_loop = 10;
+ start_counters(time, resource);
+
+ for (int j = 0; j != nb_loop; ++j)
+ for (int i = 0; i != sz; ++i)
+ s.insert(foos[i]);
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << container_desc << nb_loop << " times insertion of "
+ << sz << " elements";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+ }
+
+template<bool cache>
+ using __tr1_uset = std::tr1::__unordered_set<Foo, HashFunction,
+ std::equal_to<Foo>,
+ std::allocator<Foo>,
+ cache>;
+template<bool cache>
+ using __tr1_umset = std::tr1::__unordered_multiset<Foo, HashFunction,
+ std::equal_to<Foo>,
+ std::allocator<Foo>,
+ cache>;
+template<bool cache>
+ using __uset = std::__uset_hashtable<Foo, HashFunction,
+ std::equal_to<Foo>,
+ std::allocator<Foo>,
+ std::__uset_traits<cache>>;
+template<bool cache>
+ using __umset = std::__umset_hashtable<Foo, HashFunction,
+ std::equal_to<Foo>,
+ std::allocator<Foo>,
+ std::__uset_traits<cache>>;
+
+int main()
+{
+ using namespace __gnu_test;
+
+ {
+ int bars[sz];
+ for (int i = 0; i != sz; ++i)
+ bars[i] = i;
+ bench<std::tr1::unordered_set<int>>(
+ "std::tr1::unordered_set<int> ", bars);
+ bench<std::unordered_set<int>>(
+ "std::unordered_set<int> ", bars);
+ }
+
+ Foo foos[sz];
+#if USE_MY_FOO
+ {
+ std::random_device randev;
+ for (int i = 0; i != sz; ++i)
+ foos[i].init(randev);
+ }
+#endif
+
+ time_counter time;
+ resource_counter resource;
+ start_counters(time, resource);
+
+ bench<__tr1_uset<false>>(
+ "std::tr1::unordered_set without hash code cached ", foos);
+ bench<__tr1_uset<true>>(
+ "std::tr1::unordered_set with hash code cached ", foos);
+ bench<__tr1_umset<false>>(
+ "std::tr1::unordered_multiset without hash code cached ", foos);
+ bench<__tr1_umset<true>>(
+ "std::tr1::unordered_multiset with hash code cached ", foos);
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "tr1 benches", time, resource);
+
+ start_counters(time, resource);
+ bench<__uset<false>>(
+ "std::unordered_set without hash code cached ", foos);
+ bench<__uset<true>>(
+ "std::unordered_set with hash code cached ", foos);
+ bench<__umset<false>>(
+ "std::unordered_multiset without hash code cached ", foos);
+ bench<__umset<true>>(
+ "std::unordered_multiset with hash code cached ", foos);
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "std benches", time, resource);
+
+ bench<std::unordered_set<Foo, HashFunction>>(
+ "std::unordered_set default cache ", foos);
+ bench<std::unordered_multiset<Foo, HashFunction>>(
+ "std::unordered_multiset default cache ", foos);
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc
new file mode 100644
index 000000000..cf5b988ac
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc
@@ -0,0 +1,63 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc
new file mode 100644
index 000000000..f6dbe4c94
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc
new file mode 100644
index 000000000..0df27abd3
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_map_array.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2006-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_multiset_hint.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_multiset_hint.cc
new file mode 100644
index 000000000..ec4787336
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_multiset_hint.cc
@@ -0,0 +1,336 @@
+// Copyright (C) 2013-2014 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/>.
+
+// { dg-options "-std=gnu++11" }
+
+#include <testsuite_performance.h>
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include <unordered_set>
+
+namespace
+{
+ const int sz = 2000000;
+ const std::string pattern = "test string #";
+ const int nb_copies = 100;
+
+ // Special std::string hasher based on std::hash<std::string> but not tag as
+ // slow so that hash code is not cached. It is easier to show impact of
+ // hinting in this context.
+ struct hasher
+ {
+ std::size_t
+ operator()(const std::string& str) const noexcept
+ {
+ //std::istringstream istr(str.substr(pattern.size()));
+ //std::size_t str_index;
+ //istr >> str_index;
+ //return str_index;
+ std::hash<std::string> std_hasher;
+ return std_hasher(str);
+ }
+ };
+
+ using ums_t = std::unordered_multiset<std::string, hasher>;
+
+ void
+ insert_with_perfect_hint1(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(str));
+
+ for (int j = 1; j != nb_copies; ++j)
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ ms.insert(hints[i], strs[i]);
+ }
+
+ void
+ insert_with_perfect_hint2(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(str));
+
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ for (int j = 1; j != nb_copies; ++j)
+ ms.insert(hints[i], strs[i]);
+ }
+
+ // Always insert with the result of the previous insertion. The result of
+ // the previous insertion will never be followed by an equivalent node
+ // resulting in a re-computation of its hash code which is expensive.
+ void
+ insert_with_good_hint(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(str));
+
+ for (int j = 1; j != nb_copies; ++j)
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ hints[i] = ms.insert(hints[i], strs[i]);
+ }
+
+ // Note that the following use case is particularly bad especially compared to
+ // the solution without hint because without hint the first insertion will put
+ // it first in the bucket and following insertions will detect it and insert
+ // just before. By giving a hint insertion will be done just after forcing to
+ // check if it has no impact on the following bucket.
+ void
+ insert_with_bad_hint(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(str));
+
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ for (int j = 1; j != nb_copies; ++j)
+ hints[i] = ms.insert(hints[i], strs[i]);
+ }
+
+ void
+ insert_without_hint1(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(str));
+
+ for (int j = 1; j != nb_copies; ++j)
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ hints[i] = ms.insert(strs[i]);
+ }
+
+ // This version is the best one if you insert all equivalent elements at the
+ // same time. It demonstrates that most of the time it is better not to give
+ // any hint unless you have written a benchmark for your application showing
+ // that it does have a positive effect.
+ void
+ insert_without_hint2(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(str));
+
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ for (int j = 1; j != nb_copies; ++j)
+ hints[i] = ms.insert(strs[i]);
+ }
+
+ void
+ insert_with_any_hint1(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(ms.begin(), str));
+
+ std::size_t offset = strs.size() / 2;
+ for (int j = 1; j != nb_copies; ++j)
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ {
+ ms.insert(hints[(i + offset) % hints.size()], strs[i]);
+ ++offset;
+ }
+ }
+
+ void
+ insert_with_any_hint2(const std::vector<std::string>& strs,
+ ums_t& ms)
+ {
+ std::vector<typename ums_t::iterator> hints;
+ hints.reserve(strs.size());
+ for (auto str : strs)
+ hints.push_back(ms.insert(ms.begin(), str));
+
+ std::size_t offset = strs.size() / 2;
+ for (std::size_t i = 0; i != strs.size(); ++i)
+ for (int j = 1; j != nb_copies; ++j)
+ {
+ ms.insert(hints[(i + offset) % hints.size()], strs[i]);
+ ++offset;
+ }
+ }
+}
+
+int main()
+{
+ using namespace __gnu_test;
+
+ const int nb_iter = 10;
+
+ std::vector<std::string> strs;
+ strs.reserve(sz / nb_copies);
+
+ for (int i = 0; i != sz / nb_copies; ++i)
+ {
+ std::ostringstream osstr;
+ osstr << pattern << i;
+ strs.push_back(osstr.str());
+ }
+
+ ums_t ms;
+ // Use a large load factor to make the context ideal for using hint because we
+ // will have many elements per bucket.
+ ms.max_load_factor(10.0f);
+ ms.reserve(sz);
+
+ // Warm up.
+ {
+ for (auto str : strs)
+ for (int j = 0; j != nb_copies; ++j)
+ ms.insert(str);
+ }
+
+ time_counter time_no_hint1, time_any_hint1, time_bad_hint, time_perfect_hint1;
+ time_counter time_no_hint2, time_any_hint2, time_good_hint, time_perfect_hint2;
+ resource_counter resource_no_hint1, resource_any_hint1, resource_bad_hint,
+ resource_perfect_hint1;
+ resource_counter resource_no_hint2, resource_any_hint2, resource_good_hint,
+ resource_perfect_hint2;
+
+ for (int i = 0; i != nb_iter; ++i)
+ {
+ // Bad hint
+ {
+ ms.clear();
+ start_counters(time_bad_hint, resource_bad_hint);
+ insert_with_bad_hint(strs, ms);
+ stop_counters(time_bad_hint, resource_bad_hint);
+ }
+
+ // No hint
+ {
+ ms.clear();
+ start_counters(time_no_hint1, resource_no_hint1);
+ insert_without_hint1(strs, ms);
+ stop_counters(time_no_hint1, resource_no_hint1);
+ }
+
+ // Any hint
+ {
+ ms.clear();
+ start_counters(time_any_hint1, resource_any_hint1);
+ insert_with_any_hint1(strs, ms);
+ stop_counters(time_any_hint1, resource_any_hint1);
+ }
+
+ // Good hint
+ {
+ ms.clear();
+ start_counters(time_good_hint, resource_good_hint);
+ insert_with_good_hint(strs, ms);
+ stop_counters(time_good_hint, resource_good_hint);
+ }
+
+ // No hint
+ {
+ ms.clear();
+ start_counters(time_no_hint2, resource_no_hint2);
+ insert_without_hint2(strs, ms);
+ stop_counters(time_no_hint2, resource_no_hint2);
+ }
+
+ // Perfect hint
+ {
+ ms.clear();
+ start_counters(time_perfect_hint2, resource_perfect_hint2);
+ insert_with_perfect_hint2(strs, ms);
+ stop_counters(time_perfect_hint2, resource_perfect_hint2);
+ }
+
+ // Any hint
+ {
+ ms.clear();
+ start_counters(time_any_hint2, resource_any_hint2);
+ insert_with_any_hint2(strs, ms);
+ stop_counters(time_any_hint2, resource_any_hint2);
+ }
+
+ // Perfect hint
+ {
+ ms.clear();
+ start_counters(time_perfect_hint1, resource_perfect_hint1);
+ insert_with_perfect_hint1(strs, ms);
+ stop_counters(time_perfect_hint1, resource_perfect_hint1);
+ }
+ }
+
+ std::ostringstream ostr;
+ ostr << "unordered_set " << nb_copies << " X " << sz / nb_copies
+ << " insertions w/o hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_no_hint1, resource_no_hint1);
+
+ ostr.str("");
+ ostr << "unordered_set " << nb_copies << " X " << sz / nb_copies
+ << " insertions with any hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_any_hint1, resource_any_hint1);
+
+ ostr.str("");
+ ostr << "unordered_set " << nb_copies << " X " << sz / nb_copies
+ << " insertions with good hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_good_hint, resource_good_hint);
+
+ ostr.str("");
+ ostr << "unordered_set " << nb_copies << " X " << sz / nb_copies
+ << " insertions with perfect hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_perfect_hint1, resource_perfect_hint1);
+
+ ostr.str("");
+ ostr << "unordered_set " << sz / nb_copies << " X " << nb_copies
+ << " insertions w/o hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_no_hint2, resource_no_hint2);
+
+ ostr.str("");
+ ostr << "unordered_set " << sz / nb_copies << " X " << nb_copies
+ << " insertions with any hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_any_hint2, resource_any_hint2);
+
+ ostr.str("");
+ ostr << "unordered_set " << sz / nb_copies << " X " << nb_copies
+ << " insertions with bad hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_bad_hint, resource_bad_hint);
+
+ ostr.str("");
+ ostr << "unordered_set " << sz / nb_copies << " X " << nb_copies
+ << " insertions with perfect hint";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time_perfect_hint2, resource_perfect_hint2);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_set.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_set.cc
new file mode 100644
index 000000000..a6336ade3
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert/unordered_set.cc
@@ -0,0 +1,53 @@
+// Copyright (C) 2012-2014 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/>.
+
+// { dg-options "-std=c++11" }
+
+#include <testsuite_performance.h>
+#include <sstream>
+#ifdef _USE_TR1
+# include <tr1/unordered_set>
+using namespace std::tr1;
+const char* ns = "std::tr1::";
+#else
+# include<unordered_set>
+using namespace std;
+const char* ns = "std::";
+#endif
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int sz = 10000000;
+
+ unordered_set<int> s;
+ start_counters(time, resource);
+
+ for (int i = 0; i != sz ; ++i)
+ s.insert(i);
+
+ stop_counters(time, resource);
+ std::ostringstream ostr;
+ ostr << ns << "unordered_set " << sz << " insertions";
+ report_performance(__FILE__, ostr.str().c_str(),
+ time, resource);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc
new file mode 100644
index 000000000..4e8d45854
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/41975.cc
@@ -0,0 +1,216 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011-2014 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 <sstream>
+#include <tr1/unordered_set>
+#include <unordered_set>
+#include <testsuite_performance.h>
+
+namespace
+{
+ // Bench using an unordered_set<int>. Hash functor for int is quite
+ // predictable so it helps bench very specific use cases.
+ template<typename _ContType>
+ void bench(const char* desc)
+ {
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int nb = 200000;
+ start_counters(time, resource);
+
+ _ContType us;
+ for (int i = 0; i != nb; ++i)
+ us.insert(i);
+
+ stop_counters(time, resource);
+ std::ostringstream ostr;
+ ostr << desc << ": first insert";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ start_counters(time, resource);
+
+ // Here is the worst erase use case when hashtable implementation was
+ // something like vector<forward_list<>>. Erasing from the end was very
+ // costly because we need to return the iterator following the erased
+ // one, as the hashtable is getting emptier at each step there are
+ // more and more empty bucket to loop through to reach the end of the
+ // container and find out that it was in fact the last element.
+ for (int j = nb - 1; j >= 0; --j)
+ {
+ auto it = us.find(j);
+ if (it != us.end())
+ us.erase(it);
+ }
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": erase from iterator";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ start_counters(time, resource);
+
+ // This is a worst insertion use case for the current implementation as
+ // we insert an element at the beginning of the hashtable and then we
+ // insert starting at the end so that each time we need to seek up to the
+ // first bucket to find the first non-empty one.
+ us.insert(0);
+ for (int i = nb - 1; i >= 0; --i)
+ us.insert(i);
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": second insert";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ start_counters(time, resource);
+
+ for (int j = nb - 1; j >= 0; --j)
+ us.erase(j);
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": erase from key";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+ }
+
+ // Bench using unordered_set<string> that show how important it is to cache
+ // hash code as computing string hash code is quite expensive compared to
+ // computing it for int.
+ template<typename _ContType>
+ void bench_str(const char* desc)
+ {
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int nb = 200000;
+ // First generate once strings that are going to be used throughout the
+ // bench:
+ std::ostringstream ostr;
+ std::vector<std::string> strs;
+ strs.reserve(nb);
+ for (int i = 0; i != nb; ++i)
+ {
+ ostr.str("");
+ ostr << "string #" << i;
+ strs.push_back(ostr.str());
+ }
+
+ start_counters(time, resource);
+
+ _ContType us;
+ for (int i = 0; i != nb; ++i)
+ us.insert(strs[i]);
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": first insert";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ start_counters(time, resource);
+
+ for (int j = nb - 1; j >= 0; --j)
+ {
+ auto it = us.find(strs[j]);
+ if (it != us.end())
+ us.erase(it);
+ }
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": erase from iterator";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ start_counters(time, resource);
+
+ us.insert(strs[0]);
+ for (int i = nb - 1; i >= 0; --i)
+ us.insert(strs[i]);
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": second insert";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+
+ start_counters(time, resource);
+
+ for (int j = nb - 1; j >= 0; --j)
+ us.erase(strs[j]);
+
+ stop_counters(time, resource);
+ ostr.str("");
+ ostr << desc << ": erase from key";
+ report_performance(__FILE__, ostr.str().c_str(), time, resource);
+ }
+}
+
+template<bool cache>
+ using __uset =
+ std::__uset_hashtable<int, std::hash<int>, std::equal_to<int>,
+ std::allocator<int>,
+ std::__uset_traits<cache>>;
+
+template<bool cache>
+ using __tr1_uset =
+ std::tr1::__unordered_set<int, std::hash<int>, std::equal_to<int>,
+ std::allocator<int>,
+ cache>;
+
+template<bool cache>
+ using __str_uset =
+ std::__uset_hashtable<std::string, std::hash<std::string>,
+ std::equal_to<std::string>,
+ std::allocator<std::string>,
+ std::__uset_traits<cache>>;
+
+template<bool cache>
+ using __tr1_str_uset =
+ std::tr1::__unordered_set<std::string, std::hash<std::string>,
+ std::equal_to<std::string>,
+ std::allocator<std::string>,
+ cache>;
+
+int main()
+{
+ bench<__tr1_uset<false>>(
+ "std::tr1::unordered_set<int> without hash code cached");
+ bench<__tr1_uset<true>>(
+ "std::tr1::unordered_set<int> with hash code cached");
+ bench<__uset<false>>(
+ "std::unordered_set<int> without hash code cached");
+ bench<__uset<true>>(
+ "std::unordered_set<int> with hash code cached");
+ bench<std::unordered_set<int>>(
+ "std::unordered_set<int> default cache");
+ bench_str<__tr1_str_uset<false>>(
+ "std::tr1::unordered_set<string> without hash code cached");
+ bench_str<__tr1_str_uset<true>>(
+ "std::tr1::unordered_set<string> with hash code cached");
+ bench_str<__str_uset<false>>(
+ "std::unordered_set<string> without hash code cached");
+ bench_str<__str_uset<true>>(
+ "std::unordered_set<string> with hash code cached");
+ bench_str<std::unordered_set<std::string>>(
+ "std::unordered_set<string> default cache");
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc
new file mode 100644
index 000000000..5185d4d20
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc
@@ -0,0 +1,66 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc
new file mode 100644
index 000000000..6217d9617
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc
@@ -0,0 +1,77 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc
new file mode 100644
index 000000000..c83a945ab
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc
@@ -0,0 +1,248 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc
new file mode 100644
index 000000000..78b96df74
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc
@@ -0,0 +1,247 @@
+// Copyright (C) 2003-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc
new file mode 100644
index 000000000..4ca5603da
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/deque_construct.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2010-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc
new file mode 100644
index 000000000..56e8c8387
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct1.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 2010-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc
new file mode 100644
index 000000000..5106bd021
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/list_construct2.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2010-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc
new file mode 100644
index 000000000..5845bd469
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/range_construct/vector_construct.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2010-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc
new file mode 100644
index 000000000..4e469a313
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/resize/vector_bool.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2006-2014 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/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc
new file mode 100644
index 000000000..e4ca9c917
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc
@@ -0,0 +1,72 @@
+// Copyright (C) 2003-2014 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;
+}
+
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc
new file mode 100644
index 000000000..461dfc044
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc
@@ -0,0 +1,40 @@
+// 2009-24-12 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// 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 <deque>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const std::deque<int> data(3000, 3);
+
+ std::deque<int> d(3000, 1);
+
+ start_counters(time, resource);
+ for (int i = 0; i < 1000; ++i)
+ for (int j = 0; j < 3000; ++j)
+ std::copy_backward(data.begin(), data.begin() + j, d.end());
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc
new file mode 100644
index 000000000..35d5d79de
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_deque_iterators.cc
@@ -0,0 +1,40 @@
+// 2009-23-12 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// 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 <deque>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const std::deque<int> data(3000, 3);
+
+ std::deque<int> d(3000, 1);
+
+ start_counters(time, resource);
+ for (int i = 0; i < 1000; ++i)
+ for (int j = 0; j < 3000; ++j)
+ std::copy(data.begin(), data.begin() + j, d.begin());
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_streambuf_iterators.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_streambuf_iterators.cc
new file mode 100644
index 000000000..d77672b74
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/copy_streambuf_iterators.cc
@@ -0,0 +1,98 @@
+// Copyright (C) 2006-2014 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 <iterator>
+#include <sstream>
+#include <algorithm>
+#include <testsuite_performance.h>
+
+// libstdc++/25482
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ typedef istreambuf_iterator<char> in_iterator_type;
+ typedef ostreambuf_iterator<char> out_iterator_type;
+
+ time_counter time;
+ resource_counter resource;
+
+ const char data[] = "Contrappunto dialettico alla mente";
+
+ // istreambuf iterators -> ostreambuf iterator
+ {
+ istringstream iss(data);
+ in_iterator_type beg(iss);
+ in_iterator_type end;
+
+ ostringstream oss;
+ out_iterator_type out(oss);
+
+ start_counters(time, resource);
+ for (unsigned i = 0; i < 10000000; ++i)
+ {
+ copy(beg, end, out);
+ iss.seekg(0);
+ oss.seekp(0);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "isb iters -> osb iter", time, resource);
+ clear_counters(time, resource);
+ }
+
+ // char array -> ostreambuf iterator
+ {
+ const char* beg = data;
+ const char* end = data + sizeof(data) - 1;
+
+ ostringstream oss;
+ out_iterator_type out(oss);
+
+ start_counters(time, resource);
+ for (unsigned i = 0; i < 10000000; ++i)
+ {
+ copy(beg, end, out);
+ oss.seekp(0);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "pointers -> osb iter", time, resource);
+ clear_counters(time, resource);
+ }
+
+ // istreambuf iterators -> char array
+ {
+ istringstream iss(data);
+ in_iterator_type beg(iss);
+ in_iterator_type end;
+
+ char out[sizeof(data)];
+
+ start_counters(time, resource);
+ for (unsigned i = 0; i < 10000000; ++i)
+ {
+ copy(beg, end, out);
+ iss.seekg(0);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "isb iters -> pointer", time, resource);
+ clear_counters(time, resource);
+ }
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/find_istreambuf_iterators.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/find_istreambuf_iterators.cc
new file mode 100644
index 000000000..81b7108d5
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/find_istreambuf_iterators.cc
@@ -0,0 +1,54 @@
+// Copyright (C) 2006-2014 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 <iterator>
+#include <sstream>
+#include <algorithm>
+#include <testsuite_performance.h>
+
+// libstdc++/25482
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ typedef istreambuf_iterator<char> in_iterator_type;
+
+ istringstream iss("a0000b1111c2222d3333e4444f5555g6666h7777i8888j9999"
+ "k0000l1111m2222n3333o4444p5555q6666r7777s8888t9999");
+
+ in_iterator_type beg(iss);
+ in_iterator_type end;
+
+ time_counter time;
+ resource_counter resource;
+
+ start_counters(time, resource);
+ for (unsigned i = 0; i < 1000000; ++i)
+ {
+ for (char c = 'a'; c < 'u'; ++c)
+ {
+ find(beg, end, c);
+ iss.seekg(0);
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/lexicographical_compare.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/lexicographical_compare.cc
new file mode 100644
index 000000000..fc74d78c4
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/lexicographical_compare.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2007-2014 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++/32908
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ int cnt = 0;
+ std::vector<int> a(10000), b(10000);
+
+ start_counters(time, resource);
+ for (int i = 0; i < 100000; ++i)
+ {
+ if (a < b)
+ ++cnt;
+ if (a > b)
+ ++cnt;
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+ clear_counters(time, resource);
+
+ return cnt;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/nth_element_worst_case.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/nth_element_worst_case.cc
new file mode 100644
index 000000000..874d6715b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/nth_element_worst_case.cc
@@ -0,0 +1,53 @@
+// Copyright (C) 2006-2014 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 <algorithm>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int max_size = 8192;
+
+ std::vector<int> v[max_size];
+
+ for (int i = 0; i < max_size; ++i)
+ {
+ for (int j = 0; j < i; j += 4)
+ {
+ v[i].push_back(j / 2);
+ v[i].push_back((i - 2) - (j / 2));
+ }
+
+ for (int j = 1; j < i; j += 2)
+ v[i].push_back(j);
+ }
+
+ start_counters(time, resource);
+ for (int i = 0; i < max_size; ++i)
+ std::nth_element(v[i].begin(), v[i].begin() + i, v[i].end());
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc
new file mode 100644
index 000000000..7e9d9236d
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc
@@ -0,0 +1,63 @@
+// Copyright (C) 2004-2014 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/>.
+
+
+#define DISABLE_ITERATOR_DEBUG 1
+
+#include<cstdlib>
+#include<vector>
+#include<algorithm>
+
+#include<sstream>
+#include<testsuite_performance.h>
+#include<testsuite_iterators.h>
+
+using namespace std;
+using namespace __gnu_test;
+
+const int length = 10000000;
+const int match_length = 3;
+int ary[length];
+
+int
+main(void)
+{
+ time_counter time;
+ resource_counter resource;
+ int match = rand() % (match_length - 1);
+ for(int i = 0; i < length; i++)
+ {
+ ary[i] = (match != 0) ? 1 : 0;
+ if(--match < 0) match = rand() % (match_length - 1);
+ }
+ __gnu_test::test_container<int, forward_iterator_wrapper> fcon(ary, ary + length);
+ start_counters(time, resource);
+ for(int i = 0; i < 100; i++)
+ search_n(fcon.begin(), fcon.end(), 10, 1);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "forward iterator", time, resource);
+ clear_counters(time, resource);
+
+ __gnu_test::test_container<int, random_access_iterator_wrapper> rcon(ary, ary + length);
+ start_counters(time, resource);
+ for(int i = 0; i < 100; i++)
+ search_n(rcon.begin(), rcon.end(), 10, 1);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "random access iterator", time, resource);
+ clear_counters(time, resource);
+}
+
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort.cc
new file mode 100644
index 000000000..707eddc2c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort.cc
@@ -0,0 +1,65 @@
+// Copyright (C) 2013-2014 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 <algorithm>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int max_size = 10000000;
+
+ std::vector<int> v(max_size);
+
+ for (int i = 0; i < max_size; ++i)
+ v[i] = -i;
+
+ start_counters(time, resource);
+ std::sort(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "reverse", time, resource);
+ clear_counters(time, resource);
+
+ for (int i = 0; i < max_size; ++i)
+ v[i] = i;
+
+ start_counters(time, resource);
+ std::sort(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "forwards", time, resource);
+ clear_counters(time, resource);
+
+ // a simple psuedo-random series which does not rely on rand() and friends
+ v[0] = 0;
+ for (int i = 1; i < max_size; ++i)
+ v[i] = (v[i-1] + 110211473) * 745988807;
+
+ start_counters(time, resource);
+ std::sort(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "random", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort_heap.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort_heap.cc
new file mode 100644
index 000000000..12e162bae
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/sort_heap.cc
@@ -0,0 +1,73 @@
+// Copyright (C) 2013-2014 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 <algorithm>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int max_size = 10000000;
+
+ std::vector<int> v(max_size);
+
+ for (int i = 0; i < max_size; ++i)
+ v[i] = -i;
+
+ start_counters(time, resource);
+ std::make_heap(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "make_heap_reverse", time, resource);
+ clear_counters(time, resource);
+
+ for (int i = 0; i < max_size; ++i)
+ v[i] = i;
+
+ start_counters(time, resource);
+ std::make_heap(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "make_heap_forwards", time, resource);
+ clear_counters(time, resource);
+
+ // a simple psuedo-random series which does not rely on rand() and friends
+ v[0] = 0;
+ for (int i = 1; i < max_size; ++i)
+ v[i] = (v[i-1] + 110211473) * 745988807;
+
+ start_counters(time, resource);
+ std::make_heap(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "make_heap_random", time, resource);
+
+
+ start_counters(time, resource);
+ std::sort_heap(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "sort_heap", time, resource);
+ clear_counters(time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/stable_sort.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/stable_sort.cc
new file mode 100644
index 000000000..926f4625c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/25_algorithms/stable_sort.cc
@@ -0,0 +1,65 @@
+// Copyright (C) 2013-2014 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 <algorithm>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int max_size = 10000000;
+
+ std::vector<int> v(max_size);
+
+ for (int i = 0; i < max_size; ++i)
+ v[i] = -i;
+
+ start_counters(time, resource);
+ std::stable_sort(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "reverse", time, resource);
+ clear_counters(time, resource);
+
+ for (int i = 0; i < max_size; ++i)
+ v[i] = i;
+
+ start_counters(time, resource);
+ std::stable_sort(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "forwards", time, resource);
+ clear_counters(time, resource);
+
+ // a simple psuedo-random series which does not rely on rand() and friends
+ v[0] = 0;
+ for (int i = 1; i < max_size; ++i)
+ v[i] = (v[i-1] + 110211473) * 745988807;
+
+ start_counters(time, resource);
+ std::stable_sort(v.begin(), v.end());
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, "random", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/complex_norm.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/complex_norm.cc
new file mode 100644
index 000000000..a5c96e67d
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/complex_norm.cc
@@ -0,0 +1,74 @@
+// Copyright (C) 2003-2014 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 <complex>
+#include <testsuite_performance.h>
+
+// based on libstdc++/5730, use --fast-math
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 2000;
+
+ typedef complex<double> complex_type;
+ complex_type u[2048];
+
+ for (int i = 0; i < 2048; ++i)
+ u[i] = 1.0;
+
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ {
+ complex_type * p = u;
+ for (int j = 0; j < 2048; ++j)
+ {
+ double u2 = norm(*p);
+ double t = u2 * 0.1;
+ *p *= complex_type(cos(t), sin(t));
+ ++p;
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "norm", time, resource);
+ clear_counters(time, resource);
+
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ {
+ complex_type * p = u;
+ for (int j = 0; j < 2048; ++j)
+ {
+ // Shouldn't be slower than the above.
+ double ur = real(*p);
+ double ui = imag(*p);
+ double u2 = ur * ur + ui * ui;
+ double t = u2 * 0.1;
+ *p *= complex_type(cos(t), sin(t));
+ ++p;
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
+
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/valarray_gslice_to_index.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/valarray_gslice_to_index.cc
new file mode 100644
index 000000000..3fe780521
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/26_numerics/valarray_gslice_to_index.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2006-2014 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 <valarray>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ valarray<double> va(1000000);
+
+ for (int i = 0; i < 1000000; ++i)
+ va[i] = i;
+
+ size_t lengthvalues[] = { 10, 10, 10, 10, 10, 10 };
+ size_t stridevalues[] = { 1, 1, 1, 1, 1, 1 };
+
+ valarray<size_t> lengths(lengthvalues, 6);
+ valarray<size_t> stride(stridevalues, 6);
+
+ start_counters(time, resource);
+ for (int j = 0; j < 1000; ++j)
+ va[gslice(0, lengths, stride)];
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/cout_insert_int.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/cout_insert_int.cc
new file mode 100644
index 000000000..9c5e2939b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/cout_insert_int.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2003-2014 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 <iostream>
+#include <testsuite_performance.h>
+
+// libstdc++/7076
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 150000;
+
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; i++)
+ std::cout << i << '\n';
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_copy.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_copy.cc
new file mode 100644
index 000000000..f1694fc6a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_copy.cc
@@ -0,0 +1,66 @@
+// Copyright (C) 2003-2014 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 <cstdio>
+#include <fstream>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const unsigned long count = 1ul << 30;
+
+ // C unlocked
+ FILE* fpi = fopen("/dev/zero", "r");
+ FILE* fpo = fopen("/dev/null", "w");
+ start_counters(time, resource);
+ for (unsigned long i = 0; i < count; ++i)
+ {
+ int c = getc_unlocked(fpi);
+ if (c == EOF || putc_unlocked(c, fpo) == EOF)
+ break;
+ }
+ stop_counters(time, resource);
+ fclose(fpi);
+ fclose(fpo);
+ report_performance(__FILE__, "C unlocked", time, resource);
+ clear_counters(time, resource);
+
+ // C++
+ filebuf in;
+ in.open("/dev/zero", ios::in);
+ filebuf out;
+ out.open("/dev/null", ios::out);
+ start_counters(time, resource);
+ for (unsigned long i = 0; i < count; ++i)
+ {
+ int c = in.sbumpc();
+ if (c == EOF || out.sputc(c) == EOF)
+ break;
+ }
+ stop_counters(time, resource);
+ in.close();
+ out.close();
+ report_performance(__FILE__, "C++", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc
new file mode 100644
index 000000000..de86e1aa8
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sgetn_unbuf.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2004-2014 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 <cstdio>
+#include <cstdlib>
+#include <fstream>
+#include <testsuite_performance.h>
+
+// libstdc++/11722
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int iterations = 500000;
+ const int chunksize = 100;
+
+ char* chunk = new char[chunksize];
+ const char* name1 = "/usr/share/dict/words";
+ const char* name2 = "/usr/share/dict/linux.words";
+ const char* name = name1;
+
+ // C
+ FILE* file;
+ if (!(file = fopen(name, "r")))
+ {
+ name = name2;
+ if (!(file = fopen(name, "r")))
+ exit(1);
+ }
+ setvbuf(file, 0, _IONBF, 0);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ if (fread(chunk, 1, chunksize, file) < chunksize)
+ fseek(file, 0, SEEK_SET);
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C", time, resource);
+ clear_counters(time, resource);
+
+ // C unlocked
+ file = fopen(name, "r");
+ setvbuf(file, 0, _IONBF, 0);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ if (fread_unlocked(chunk, 1, chunksize, file) < chunksize)
+ fseek(file, 0, SEEK_SET);
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C unlocked", time, resource);
+ clear_counters(time, resource);
+
+ // C++
+ filebuf buf;
+ buf.pubsetbuf(0, 0);
+ buf.open(name, ios_base::in);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ if (buf.sgetn(chunk, chunksize) < chunksize)
+ buf.pubseekoff(0, ios::beg);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++", time, resource);
+
+ delete [] chunk;
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputc.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputc.cc
new file mode 100644
index 000000000..373eb323c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputc.cc
@@ -0,0 +1,65 @@
+// Copyright (C) 2003-2014 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 <unistd.h>
+#include <cstdio>
+#include <fstream>
+#include <testsuite_performance.h>
+
+// libstdc++/9876
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 100000000;
+
+ // C
+ FILE* file = fopen("tmp", "w+");
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ putc(i % 100, file);
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C", time, resource);
+ clear_counters(time, resource);
+
+ // C unlocked
+ file = fopen("tmp", "w+");
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ putc_unlocked(i % 100, file);
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C unlocked", time, resource);
+ clear_counters(time, resource);
+
+
+ // C++
+ filebuf buf;
+ buf.open("tmp", ios_base::out | ios_base::in | ios_base::trunc);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ buf.sputc(i % 100);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++", time, resource);
+
+ unlink("tmp");
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc
new file mode 100644
index 000000000..374941baf
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc
@@ -0,0 +1,73 @@
+// Copyright (C) 2004-2014 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 <unistd.h>
+#include <cstdio>
+#include <fstream>
+#include <testsuite_performance.h>
+
+// libstdc++/11378
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const int iterations = 500000;
+ const int chunksize = 100;
+
+ char* chunk = new char[chunksize];
+
+ // C
+ FILE* file = fopen("tmp", "w+");
+ setvbuf(file, 0, _IONBF, 0);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ fwrite(chunk, 1, chunksize, file);
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C", time, resource);
+ clear_counters(time, resource);
+
+ // C unlocked
+ file = fopen("tmp", "w+");
+ setvbuf(file, 0, _IONBF, 0);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ fwrite_unlocked(chunk, 1, chunksize, file);
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C unlocked", time, resource);
+ clear_counters(time, resource);
+
+ // C++
+ filebuf buf;
+ buf.pubsetbuf(0, 0);
+ buf.open("tmp", ios_base::out | ios_base::in | ios_base::trunc);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ buf.sputn(chunk, chunksize);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++", time, resource);
+
+ unlink("tmp");
+ delete [] chunk;
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fmtflags_manipulators.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fmtflags_manipulators.cc
new file mode 100644
index 000000000..c90c01ffc
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fmtflags_manipulators.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2004-2014 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 <cstdlib>
+#include <sstream>
+#include <testsuite_performance.h>
+
+// libstdc++/14078
+int main(int argc, char** argv)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ int iters = 50000000;
+ if (argc > 1)
+ iters = atoi(argv[1]);
+
+ ostringstream os_s, os_m;
+
+ // setf
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ {
+ os_s.setf(ios_base::uppercase);
+ os_s.unsetf(ios_base::uppercase);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "setf", time, resource);
+ clear_counters(time, resource);
+
+ // manipulator
+ start_counters(time, resource);
+ for (int i = 0; i < iters; ++i)
+ {
+ os_m << uppercase;
+ os_m << nouppercase;
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "manipulator", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fstream_seek_write.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fstream_seek_write.cc
new file mode 100644
index 000000000..be12378a6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/fstream_seek_write.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2003-2014 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 <unistd.h>
+#include <fstream>
+#include <testsuite_performance.h>
+
+// libstdc++/10672
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 300000;
+
+ fstream s("tmp_perf_seek", ios::binary | ios::in | ios::out | ios::trunc);
+ if (s.good())
+ {
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; i++)
+ {
+ s.seekp(0);
+ s.write((char *) & i, sizeof(int));
+ s.seekp(sizeof(int));
+ s.write((char *) & i, sizeof(int));
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+ }
+
+ unlink("tmp_perf_seek");
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc
new file mode 100644
index 000000000..667198686
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc
@@ -0,0 +1,82 @@
+// Copyright (C) 2005-2014 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 <unistd.h>
+#include <cstdio>
+#include <fstream>
+#include <string>
+#include <testsuite_performance.h>
+
+// libstdc++/22515
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const char filename[] = "tmp_perf_chars.txt";
+ const unsigned lines = 200000;
+ const unsigned line_length = 200;
+
+ char* line = new char[line_length + 2];
+
+ // Construct data.
+ {
+ memset(line, 'x', line_length);
+ line[line_length] = '\n';
+ line[line_length + 1] = '\0';
+
+ ofstream out(filename);
+ for (unsigned i = 0; i < lines; ++i)
+ out << line;
+ }
+
+ // operator>>(basic_istream<char>& __in, basic_string<char>& __str)
+ {
+ start_counters(time, resource);
+ for (int iter = 0; iter < 25; ++iter)
+ {
+ ifstream file(filename);
+ string string_line;
+
+ while (file >> string_line);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "string&", time, resource);
+ clear_counters(time, resource);
+ }
+
+ // operator>>(basic_istream<char>& __in, char* __s)
+ {
+ start_counters(time, resource);
+ for (int iter = 0; iter < 25; ++iter)
+ {
+ ifstream file(filename);
+
+ while (file >> line);
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "char*", time, resource);
+ clear_counters(time, resource);
+ }
+
+ delete[] line;
+ unlink(filename);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_float.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_float.cc
new file mode 100644
index 000000000..ca0517bdf
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_float.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2004-2014 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 <unistd.h>
+#include <fstream>
+#include <sstream>
+#include <testsuite_performance.h>
+
+void test_extraction(int p = 6)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ const char* filename = "tmp_perf_float.txt";
+ const int iterations = 10000000;
+
+ ostringstream oss;
+ oss << "precision " << p;
+
+ // Construct data.
+ {
+ ofstream out(filename);
+ out.precision(p);
+ for (int i = 0; i < iterations; ++i)
+ {
+ float f = i * 3.14159265358979323846;
+ out << f << '\n';
+ }
+ }
+
+ {
+ time_counter time;
+ resource_counter resource;
+
+ ifstream in(filename);
+ in.precision(p);
+ float f;
+ start_counters(time, resource);
+ for (int j, i = 0; i < iterations; ++i)
+ in >> f;
+ stop_counters(time, resource);
+ report_performance(__FILE__, oss.str(), time, resource);
+ }
+
+ unlink(filename);
+};
+
+int main()
+{
+ test_extraction(6);
+ test_extraction(12);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_int.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_int.cc
new file mode 100644
index 000000000..86802b689
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_int.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2003-2014 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 <unistd.h>
+#include <fstream>
+#include <testsuite_performance.h>
+
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 10000000;
+
+ {
+ ofstream out("tmp_perf_int.txt");
+ for (int i = 0; i < iterations; ++i)
+ out << i << "\n";
+ }
+
+ {
+ ifstream in("tmp_perf_int.txt");
+ start_counters(time, resource);
+ for (int j, i = 0; i < iterations; ++i)
+ in >> j;
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+ }
+
+ unlink("tmp_perf_int.txt");
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline-2.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline-2.cc
new file mode 100644
index 000000000..b3ec9215b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline-2.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2004-2014 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 <unistd.h>
+#include <cstdio>
+#include <fstream>
+#include <string>
+#include <testsuite_performance.h>
+
+// libstdc++/15002
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const char filename[] = "tmp_getline.txt";
+ const unsigned lines = 1000000;
+ const unsigned line_length = 200;
+
+ char* line = new char[line_length + 2];
+
+ // Construct data.
+ {
+ memset(line, 'x', line_length);
+ line[line_length] = '\n';
+ line[line_length + 1] = '\0';
+
+ ofstream out(filename);
+ for (unsigned i = 0; i < lines; ++i)
+ out << line;
+ }
+
+ // C
+ {
+ // Fill the cache.
+ FILE *file = fopen(filename, "r");
+ while (fgets(line, line_length + 2, file));
+ fclose(file);
+
+ file = fopen(filename, "r");
+ start_counters(time, resource);
+ while (fgets(line, line_length + 2, file));
+ stop_counters(time, resource);
+ fclose(file);
+ report_performance(__FILE__, "C (fgets)", time, resource);
+ clear_counters(time, resource);
+ }
+
+ // getline(basic_istream<_CharT, _Traits>& __in,
+ // basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim)
+ {
+ ifstream file(filename);
+ string string_line;
+
+ start_counters(time, resource);
+ while (getline(file, string_line));
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++ (string)", time, resource);
+ clear_counters(time, resource);
+ }
+
+ // getline(char_type* __s, streamsize __n, char_type __delim)
+ {
+ ifstream file(filename);
+
+ start_counters(time, resource);
+ while (file.getline(line, line_length + 2));
+ stop_counters(time, resource);
+ report_performance(__FILE__, "C++ (char array)", time, resource);
+ clear_counters(time, resource);
+ }
+
+ delete[] line;
+ unlink(filename);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline.cc
new file mode 100644
index 000000000..9abaef6fe
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ifstream_getline.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2003-2014 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 <fstream>
+#include <cstdlib>
+#include <testsuite_performance.h>
+
+// libstdc++/5001 (100,000 line input file)
+int main ()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ const char* name1 = "/usr/share/dict/words";
+ const char* name2 = "/usr/share/dict/linux.words";
+ ifstream in;
+ in.open(name1);
+ if (!in.is_open())
+ {
+ in.clear();
+ in.open(name2);
+ }
+ if (!in.is_open())
+ exit(1);
+
+ char buffer[BUFSIZ];
+ start_counters(time, resource);
+ while (in.good())
+ in.getline(buffer, BUFSIZ);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_float.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_float.cc
new file mode 100644
index 000000000..2b4a8026c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_float.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2003-2014 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 <unistd.h>
+#include <fstream>
+#include <sstream>
+#include <testsuite_performance.h>
+
+// Based on libstdc++/8761 poor fstream performance (converted to float)
+void test_insertion(int p = 6)
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ const char* filename = "tmp_perf_float.txt";
+ const int iterations = 10000000;
+
+ ostringstream oss;
+ oss << "precision " << p;
+
+ {
+ time_counter time;
+ resource_counter resource;
+
+ ofstream out(filename);
+ out.precision(p);
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ {
+ float f = i * 3.14159265358979323846;
+ out << f << '\n';
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, oss.str(), time, resource);
+ }
+
+ unlink(filename);
+};
+
+int main()
+{
+ test_insertion(6);
+ test_insertion(12);
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_int.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_int.cc
new file mode 100644
index 000000000..2de9c5493
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/ofstream_insert_int.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2003-2014 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 <unistd.h>
+#include <fstream>
+#include <testsuite_performance.h>
+
+// libstdc++/8761 poor fstream performance
+int main()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 10000000;
+
+ ofstream out("tmp_perf_int.txt");
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ out << i << "\n";
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ unlink("tmp_perf_int.txt");
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/stringbuf_overflow.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/stringbuf_overflow.cc
new file mode 100644
index 000000000..c59a58cdc
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/27_io/stringbuf_overflow.cc
@@ -0,0 +1,51 @@
+// Copyright (C) 2004-2014 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 <sstream>
+#include <testsuite_performance.h>
+
+// libstdc++/16401 ostringstream in gcc 3.4.x very slow for big data
+void test01()
+{
+ using namespace std;
+ using namespace __gnu_test;
+
+ time_counter time;
+ resource_counter resource;
+
+ for(unsigned n = 10000; n <= 10000000; n *= 10)
+ {
+ ostringstream oss;
+ oss << "size = " << n;
+
+ ostringstream str;
+ start_counters(time, resource);
+ for(unsigned i = 0; i < n; ++i)
+ str << 'a';
+ stop_counters(time, resource);
+
+ report_performance(__FILE__, oss.str(), time, resource);
+ clear_counters(time, resource);
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.cc
new file mode 100644
index 000000000..8ae75a188
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2013-2014 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/>.
+
+// 2013-10-08 Tim Shen <timshen91@gmail.com>
+
+#include <testsuite_performance.h>
+#include "split.h"
+
+using namespace __gnu_test;
+
+int main()
+{
+ time_counter time;
+ resource_counter resource;
+
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+
+ start_counters(time, resource);
+ split(source);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.h b/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.h
new file mode 100644
index 000000000..79c36bc6e
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split.h
@@ -0,0 +1,91 @@
+// Copyright (C) 2013-2014 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/>.
+
+// 2013-10-26 Tim Shen <timshen91@gmail.com>
+
+#include <regex>
+
+using namespace std;
+
+void split(string s)
+{
+ regex re("\\s+");
+ for (auto it = sregex_token_iterator(s.begin(), s.end(), re, -1);
+ it != sregex_token_iterator();
+ ++it)
+ {
+ }
+}
+
+string source = "\
+// Copyright (C) 2013-2014 Free Software Foundation, Inc.\n\
+//\n\
+// This file is part of the GNU ISO C++ Library. This library is free\n\
+// software; you can redistribute it and/or modify it under the\n\
+// terms of the GNU General Public License as published by the\n\
+// Free Software Foundation; either version 3, or (at your option)\n\
+// any later version.\n\
+\n\
+// This library is distributed in the hope that it will be useful,\n\
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
+// GNU General Public License for more details.\n\
+\n\
+// You should have received a copy of the GNU General Public License along\n\
+// with this library; see the file COPYING3. If not see\n\
+// <http://www.gnu.org/licenses/>.\n\
+\n\
+// 2013-10-08 Tim Shen <timshen91@gmail.com>\n\
+\n\
+#include <testsuite_performance.h>\n\
+#include <regex>\n\
+\n\
+using namespace __gnu_test;\n\
+using namespace std;\n\
+\n\
+void split(string s)\n\
+{\n\
+ regex re(\"\\s+\");\n\
+ for (auto it = sregex_token_iterator(s.begin(), s.end(), re, -1);\n\
+ it != sregex_token_iterator();\n\
+ ++it)\n\
+ {\n\
+ }\n\
+}\n\
+\n\
+int main()\n\
+{\n\
+ string source = \"\";\n\
+ time_counter time;\n\
+ resource_counter resource;\n\
+\n\
+ source = source + source;\n\
+ source = source + source;\n\
+ source = source + source;\n\
+ source = source + source;\n\
+ source = source + source;\n\
+ source = source + source;\n\
+ source = source + source;\n\
+ source = source + source;\n\
+\n\
+ start_counters(time, resource);\n\
+ split(source);\n\
+ stop_counters(time, resource);\n\
+ report_performance(__FILE__, \"\", time, resource);\n\
+\n\
+ return 0;\n\
+}\n";
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split_bfs.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split_bfs.cc
new file mode 100644
index 000000000..1c07086f4
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/28_regex/split_bfs.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2013-2014 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/>.
+
+// 2013-10-26 Tim Shen <timshen91@gmail.com>
+
+#include <testsuite_performance.h>
+#define _GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT 0
+#include "split.h"
+
+using namespace __gnu_test;
+
+int main()
+{
+ time_counter time;
+ resource_counter resource;
+
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+ source = source + source;
+
+ start_counters(time, resource);
+ split(source);
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc
new file mode 100644
index 000000000..799902910
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc
@@ -0,0 +1,64 @@
+// Copyright (C) 2009-2014 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 <future>
+#include <thread>
+#include <testsuite_performance.h>
+
+inline bool is_ready(std::shared_future<void>& f)
+{
+ return f.wait_for(std::chrono::microseconds(1)) == std::future_status::ready;
+}
+
+void poll(std::shared_future<void> f)
+{
+ while (!is_ready(f))
+ { }
+}
+
+int main()
+{
+#ifdef TEST_T1
+#define thread_type true
+#endif
+
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+
+ const int n = 20;
+ std::promise<void> p;
+ std::shared_future<void> f = p.get_future();
+ std::thread pollers[n];
+ for (int i=0; i < n; ++i)
+ pollers[i] = std::thread(poll, f);
+
+ start_counters(time, resource);
+
+ for (int i = 0; i < 1000000; ++i)
+ (void)is_ready(f);
+ p.set_value();
+
+ for (int i=0; i < n; ++i)
+ pollers[i].join();
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_find.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_find.cc
new file mode 100644
index 000000000..edd6697ac
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_find.cc
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file random_int_find_timing_test.cpp
+ * Contains test for finding random integers.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_map.hpp>
+#include <native_type/native_map.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/find_test.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector< std::pair< int, char> > vec_t;
+ vec_t a_v(vm);
+ twister_rand_gen g;
+ for (size_t i = 0; i < vm; ++i)
+ a_v[i] = std::make_pair(static_cast<int>(g.get_unsigned_long()), 0);
+ vec_t::const_iterator b = a_v.begin();
+
+ typedef find_test< vec_t::const_iterator> test_t;
+ test_t tst(b, b, vn, vs, vm, vn, vs, vm);
+ {
+ typedef native_hash_map< int, char> native_t;
+ tst(native_t());
+ }
+
+ {
+ typedef native_map< int, char> native_t;
+ tst(native_t());
+ }
+
+ {
+ typedef hash_common_types<int, char>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef tree_common_types<int, char>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: hash_random_int_find_timing_test <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their find method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of random integers " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Performs a sequence of find operations. At each iteration, "
+ "it finds, for each integer in the vector, its entry in the "
+ "container, using the find method";
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_find.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_find.cc
new file mode 100644
index 000000000..385478092
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_find.cc
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file random_int_subscript_find_timing_test.cpp
+ * Contains test for subscripting random integers.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_map.hpp>
+#include <native_type/native_map.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/subscript_find_test.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<int, size_t> > vec_t;
+ vec_t a_v(vm);
+ twister_rand_gen g;
+ for (size_t i = 0; i < vm; ++i)
+ a_v[i] = std::make_pair(static_cast<int>(g.get_unsigned_long()), 0);
+ vec_t::const_iterator b = a_v.begin();
+
+ typedef subscript_find_test<vec_t::const_iterator> test_t;
+ test_t tst(b, b, vn, vs, vm, vn, vs, vm);
+ {
+ typedef hash_common_types<int, size_t>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef tree_common_types<int, size_t>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_hash_map<int, size_t> native_t;
+ tst(native_t());
+ }
+
+ {
+ typedef native_map< int, size_t> native_t;
+ tst(native_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: hash_random_int_subscript_find_timing_test <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their find method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of random integers " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Performs a sequence of find operations. At each iteration, "
+ "it finds, for each integer in the vector, its entry in the "
+ "container, using the subscript operator";
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_insert.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_insert.cc
new file mode 100644
index 000000000..00c47c4cd
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_int_subscript_insert.cc
@@ -0,0 +1,123 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file random_int_subscript_insert_timing_test.cpp
+ * Contains test for subscripting random integers.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_map.hpp>
+#include <native_type/native_map.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/subscript_insert_test.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<int, size_t> > vec_t;
+ vec_t a_v(vm);
+ twister_rand_gen g;
+
+ for (size_t i = 0; i < vm; ++i)
+ a_v[i] = std::make_pair(static_cast<int>(g.get_unsigned_long()), 0);
+ vec_t::const_iterator b = a_v.begin();
+
+ typedef subscript_insert_test<vec_t::const_iterator> test_t;
+ test_t tst(b, b, vn, vs, vm, vn, vs, vm);
+ {
+ typedef hash_common_types<int, size_t>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef tree_common_types<int, size_t>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_hash_map< int, size_t> native_t;
+ tst(native_t());
+ }
+
+ {
+ typedef native_map< int, size_t> native_t;
+ tst(native_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: hash_random_int_subscript_insert_timing_test <vn> <vs> <vm>"
+ << endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their find method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of random integers " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc
new file mode 100644
index 000000000..a92ccd2b0
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc
@@ -0,0 +1,145 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file text_find_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/find_test.hpp>
+#include <io/text_populate.hpp>
+#include <hash_fn/string_hash_fn.hpp>
+#include <native_type/native_hash_map.hpp>
+#include <native_type/native_map.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+ typedef find_test<vec_t::const_iterator, false> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, b, vn, vs, vm, vn, vs, vm);
+ {
+ typedef trie_common_types<std::string, char>::performance_tl pat_trie_tl_t;
+
+ typedef tree_common_types<std::string, char>::performance_tl tree_tl_t;
+
+ typedef hash_common_types<std::string, char, string_hash_fn>::performance_tl hash_tl_t;
+
+ typedef __gnu_cxx::typelist::append<pat_trie_tl_t, __gnu_cxx::typelist::append<hash_tl_t, tree_tl_t>::type>::type tl_t;
+
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_map<std::string, char> native_map_t;
+ tst(native_map_t());
+
+#ifdef PB_DS_USE_TR1
+ typedef native_hash_map<std::string, char, 8, string_hash_fn> native_hash_map_t;
+ tst(native_hash_map_t());
+
+ typedef
+ native_hash_map<
+ std::string,
+ char,
+ 8,
+ string_hash_fn,
+ std::equal_to<
+ std::string>,
+ std::less<
+ std::string>,
+ std::allocator<
+ char>,
+ true>
+ sth_native_hash_map_t;
+
+ tst(sth_native_hash_map_t());
+#endif
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: text_find_timing_test <f_name> <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their find method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Performs a sequence of find operations. At each iteration, "
+ "it finds, for each word in the vector, its entry in the "
+ "container, using the find method" << endl;
+ cerr << "* Repeats the above test a number of times) "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_int_erase_mem.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_int_erase_mem.cc
new file mode 100644
index 000000000..593f5dcb2
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_int_erase_mem.cc
@@ -0,0 +1,118 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_random_int_erase_mem_usage_test.cpp
+ * Contains test for erasing random integers.
+ */
+
+#include <ext/typelist.h>
+#include <testsuite_allocator.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/mem_usage/erase_test.hpp>
+#include <iostream>
+#include <vector>
+#include <functional>
+
+struct int_hash : public std::unary_function<int, int>
+{
+ inline int
+ operator()(int i) const
+ { return i; }
+};
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Memory (bytes)");
+
+ typedef std::vector<int> vec_t;
+ vec_t a_v(vm);
+ twister_rand_gen g;
+ for (size_t i = 0; i < vm; ++i)
+ a_v[i] = static_cast<int>(g.get_unsigned_long());
+
+ vec_t::const_iterator b = a_v.begin();
+ erase_test<vec_t::const_iterator> tst(b, vn, vs, vm);
+ typedef __gnu_test::tracker_allocator<char> alloc_t;
+ {
+ typedef hash_common_types<int, __gnu_pbds::null_type, int_hash, std::equal_to<int>, alloc_t>::performance_tl tl_t;
+
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_hash_set<int, 8, int_hash, std::equal_to<int>, std::less<int>, alloc_t> native_t;
+
+ tst(native_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: hash_random_int_erase_if_test <vn> <vs> <vm>"
+ << endl << endl;
+
+ cerr << "This test checks the performance of various associative containers "
+ "using their erase method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of random integers " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Erases all the elements, except one, from the constainer"
+ << endl << endl;
+
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_int_find.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_int_find.cc
new file mode 100644
index 000000000..fd753da66
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_zlob_int_find.cc
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_zlob_random_int_find_timing_test.cpp
+ * Contains test for finding random integers.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_set.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/find_test.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<int, char> > vec_t;
+ vec_t a_v(vm);
+ twister_rand_gen g;
+
+ for (size_t i = 0; i < vm; ++i)
+ {
+ int k = static_cast<int>(g.get_unsigned_long());
+ a_v[i] = std::make_pair(k << 8, 0);
+ if ((a_v[i].first& 127) != 0)
+ throw std::logic_error("Fucked!");
+ }
+
+ vec_t::const_iterator b = a_v.begin();
+ typedef find_test<vec_t::const_iterator> test_t;
+ test_t tst(b, b, vn, vs, vm, vn, vs, vm);
+ {
+ typedef native_hash_map<int, char> native_t;
+ tst(native_t());
+ }
+
+ {
+ typedef hash_common_types<int, char>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: hash_zlob_random_int_find_timing_test <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their find method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of zero low-order bit random integers " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Performs a sequence of find operations. At each iteration, "
+ "it finds, for each integer in the vector, its entry in the "
+ "container, using the find method";
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp
new file mode 100644
index 000000000..686bf4176
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp
@@ -0,0 +1,137 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_text_find_timing_test.cpp
+ * Contains test for inserting text words.
+ */
+
+#include <ext/typelist.h>
+#include <io/text_populate.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_multimap.hpp>
+#include <native_type/native_multimap.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/multimap_find_test.hpp>
+#include <performance/assoc/multimap_common_type.hpp>
+#include <hash_fn/string_hash_fn.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+void
+set_test_parameters(size_t& n, size_t&s, size_t& m, size_t& prm);
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t prm;
+ size_t ratio_n;
+ size_t ratio_s;
+ size_t ratio_m;
+
+
+ set_test_parameters(prm, ratio_n, ratio_s, ratio_m);
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, int> > vec_t;
+ vec_t a_v_init(prm);
+ distinct_text_populate(f_name, a_v_init);
+
+ vec_t a_v;
+ twister_rand_gen g;
+ for (size_t i = 0; i < ratio_m; ++i)
+ for (size_t j = 0; j < a_v_init.size(); ++j)
+ a_v.push_back(std::make_pair(a_v_init[j].first,
+ static_cast<int>(g.get_unsigned_long())));
+
+ vec_t::const_iterator b = a_v.begin();
+ {
+ typedef mmap_tl_t<std::string, int, std::allocator<char> >::type mmap_tl_tl;
+ mmap_tl_tl tl;
+
+ typedef multimap_find_test<vec_t::const_iterator, false> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_hash_multimap<std::string, int, 8, string_hash_fn> native_t;
+ typedef multimap_find_test<vec_t::const_iterator, true> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ tst(native_t());
+ }
+
+ {
+ typedef native_multimap<std::string, int> native_t;
+ typedef multimap_find_test<vec_t::const_iterator, true> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ tst(native_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: multimap_text_insert_test.out <prm> <ratio_n> <ratio_s> <ratio_m>"
+ << endl << endl;
+
+ cerr << "This test checks the performance of various associative containers "
+ "using their insert method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of pairs of text words" << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times" << endl;
+ cerr << endl << endl;
+
+ cerr << "prm = maximum size of distinct pair-first entries" << endl;
+ cerr << "ratio_n = minimum ratio of secondary keys to primary keys" << endl;
+ cerr << "ratio_s = step ratio of secondary keys to primary keys" << endl;
+ cerr << "ratio_m = maximum ratio of secondary keys to primary keys" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_large.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_large.cc
new file mode 100644
index 000000000..3f24de5f4
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_large.cc
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "multimap_text_find.hpp"
+
+void
+set_test_parameters(size_t& prm, size_t&n, size_t& s, size_t& m)
+{
+ prm = 100;
+ n = 3;
+ s = 4;
+ m = 20;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_small.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_small.cc
new file mode 100644
index 000000000..f95b8ce32
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find_small.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "multimap_text_find.hpp"
+
+void
+set_test_parameters(size_t& prm, size_t&n, size_t& s, size_t& m)
+{
+ prm = 400;
+ n = 1;
+ s = 1;
+ m = 6;
+}
+
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp
new file mode 100644
index 000000000..460e13ec8
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp
@@ -0,0 +1,137 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_text_insert_timing_test.cpp
+ * Contains test for inserting text words.
+ */
+
+#include <ext/typelist.h>
+#include <io/text_populate.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_multimap.hpp>
+#include <native_type/native_multimap.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/multimap_insert_test.hpp>
+#include <performance/assoc/multimap_common_type.hpp>
+#include <hash_fn/string_hash_fn.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+void
+set_test_parameters(size_t& n, size_t&s, size_t& m, size_t& prm);
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t prm;
+ size_t ratio_n;
+ size_t ratio_s;
+ size_t ratio_m;
+
+ set_test_parameters(prm, ratio_n, ratio_s, ratio_m);
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, int> > vec_t;
+ vec_t a_v_init(prm);
+ distinct_text_populate(f_name, a_v_init);
+
+ vec_t a_v;
+ twister_rand_gen g;
+ for (size_t i = 0; i < ratio_m; ++i)
+ for (size_t j = 0; j < a_v_init.size(); ++j)
+ a_v.push_back(std::make_pair(a_v_init[j].first,
+ static_cast<int>(g.get_unsigned_long())));
+
+ vec_t::const_iterator b = a_v.begin();
+ {
+ typedef mmap_tl_t<std::string, int, std::allocator<char> >::type mmap_tl_tl;
+ mmap_tl_tl tl;
+ typedef multimap_insert_test<vec_t::const_iterator, false> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_hash_multimap<std::string, int, 8, string_hash_fn> native_t;
+ typedef multimap_insert_test<vec_t::const_iterator, true> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ tst(native_t());
+ }
+
+ {
+ typedef native_multimap<std::string, int> native_t;
+ typedef multimap_insert_test<vec_t::const_iterator, true> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ tst(native_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: multimap_text_insert_test.out <prm> <ratio_n> <ratio_s> <ratio_m>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their insert method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of pairs of text words" << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "prm = maximum size of distinct pair-first entries" << endl;
+ cerr << "ratio_n = minimum ratio of secondary keys to primary keys" << endl;
+ cerr << "ratio_s = step ratio of secondary keys to primary keys" << endl;
+ cerr << "ratio_m = maximum ratio of secondary keys to primary keys" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_large.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_large.cc
new file mode 100644
index 000000000..02a0af981
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_large.cc
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "multimap_text_insert.hpp"
+
+void
+set_test_parameters(size_t& prm, size_t&n, size_t& s, size_t& m)
+{
+ prm = 100;
+ n = 3;
+ s = 4;
+ m = 20;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp
new file mode 100644
index 000000000..461ca7c6a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp
@@ -0,0 +1,155 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_text_insert_mem_usage_test.cpp
+ * Contains test for inserting text words.
+ */
+
+#include <iostream>
+#include <vector>
+#include <ext/typelist.h>
+#include <testsuite_allocator.h>
+#include <io/text_populate.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <native_type/native_hash_multimap.hpp>
+#include <native_type/native_multimap.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/mem_usage/multimap_insert_test.hpp>
+#include <performance/assoc/multimap_common_type.hpp>
+#include <hash_fn/string_hash_fn.hpp>
+
+void
+usage();
+
+void
+set_test_parameters(size_t& n, size_t&s, size_t& m, size_t& prm);
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t prm;
+ size_t ratio_n;
+ size_t ratio_s;
+ size_t ratio_m;
+
+ set_test_parameters(prm, ratio_n, ratio_s, ratio_m);
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Memory (bytes)");
+
+ typedef std::vector<std::pair<std::string, int> > init_vec_t;
+ init_vec_t a_v_init(prm);
+ distinct_text_populate(f_name, a_v_init);
+
+ typedef __gnu_test::tracker_allocator<char> alloc_t;
+ typedef std::basic_string<char, std::char_traits<char>, alloc_t> string_t;
+ typedef std::vector<std::pair<string_t, int> > vec_t;
+ vec_t a_v;
+ twister_rand_gen g;
+ for (size_t i = 0; i < ratio_m; ++i)
+ for (size_t j = 0; j < a_v_init.size(); ++j)
+ a_v.push_back(std::make_pair(string_t(a_v_init[j].first.begin(), a_v_init[j].first.end()), static_cast<int>(g.get_unsigned_long())));
+
+ vec_t::const_iterator b = a_v.begin();
+ {
+ typedef mmap_tl_t<string_t, int, alloc_t>::type tl_t;
+ tl_t tl;
+ typedef multimap_insert_test<vec_t::const_iterator, false> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef mmap_tl_t< string_t, int, alloc_t>::type tl_t;
+ tl_t tl;
+ typedef multimap_insert_test<vec_t::const_iterator, false> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ typedef multimap_insert_test<vec_t::const_iterator, true> test_type;
+ test_type tst(b, prm* ratio_n, prm* ratio_s, prm* ratio_m);
+ {
+ typedef native_multimap<string_t, int, std::less<string_t>, alloc_t> native_t;
+ tst(native_t());
+ }
+
+ {
+ typedef
+ native_hash_multimap<
+ string_t,
+ int,
+ 8,
+ string_hash_fn, std::equal_to<string_t>,
+ std::less<string_t>,
+ alloc_t>
+ native_t;
+
+ tst(native_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: multimap_text_insert_test.out <prm> <ratio_n> <ratio_s> <ratio_m>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their insert method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of pairs of text words" << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "prm = maximum size of distinct pair-first entries" << endl;
+ cerr << "ratio_n = minimum ratio of secondary keys to primary keys" << endl;
+ cerr << "ratio_s = step ratio of secondary keys to primary keys" << endl;
+ cerr << "ratio_m = maximum ratio of secondary keys to primary keys" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_large.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_large.cc
new file mode 100644
index 000000000..df3da5379
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_large.cc
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "multimap_text_insert_mem.hpp"
+
+void
+set_test_parameters(size_t& prm, size_t&n, size_t& s, size_t& m)
+{
+ prm = 100;
+ n = 3;
+ s = 4;
+ m = 20;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_small.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_small.cc
new file mode 100644
index 000000000..623772214
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_small.cc
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "multimap_text_insert_mem.hpp"
+
+void
+set_test_parameters(size_t& prm, size_t&n, size_t& s, size_t& m)
+{
+ prm = 400;
+ n = 1;
+ s = 1;
+ m = 6;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_small.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_small.cc
new file mode 100644
index 000000000..beb0d0936
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_small.cc
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "multimap_text_insert.hpp"
+
+void
+set_test_parameters(size_t& prm, size_t&n, size_t& s, size_t& m)
+{
+ prm = 400;
+ n = 1;
+ s = 1;
+ m = 6;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push.cc
new file mode 100644
index 000000000..ffd9b7cfa
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push.cc
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_random_int_push_timing_test.cpp
+ * Contains test for finding random_int.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/timing/push_test.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <testsuite_rng.h>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<int, char> > vec_t;
+ vec_t a_v(vm);
+ twister_rand_gen g;
+ for (size_t i = 0; i < vm; ++i)
+ a_v[i] = std::make_pair(static_cast<int>(g.get_unsigned_long()), 0);
+
+ typedef push_test<vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm);
+ {
+ typedef pq_common_types<int>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<int, true> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<int, false> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: priority_queue_random_int_push_timing_test <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various priority_queue containers "
+ "using their push method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of random integers " << endl;
+ cerr << "* Pushes the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push_pop.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push_pop.cc
new file mode 100644
index 000000000..fc19c0cd7
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_int_push_pop.cc
@@ -0,0 +1,118 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_random_int_push_pop_timing_test.cpp
+ * Contains test for finding random_int.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/timing/push_pop_test.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <testsuite_rng.h>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<int, char> > vector_type;
+ vector_type a_v(vm);
+ twister_rand_gen g;
+
+ for (size_t i = 0; i < vm; ++i)
+ a_v[i] = std::make_pair(static_cast<int>(g.get_unsigned_long()), 0);
+ vector_type::const_iterator b = a_v.begin();
+
+ typedef push_pop_test<vector_type::const_iterator> test_type;
+ test_type tst(b, vn, vs, vm);
+ {
+ typedef pq_common_types<int>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<int, true> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<int, false> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ std::cerr << "usage: priority_queue_random_int_push_pop_timing_test <vn> <vs> <vm>" <<
+ std::endl << std::endl;
+
+ std::cerr <<
+ "This test checks the performance of various priority_queue containers "
+ "using their push and pop method. " << std::endl;
+ std::cerr << "Specifically, it does the following:" << std::endl;
+ std::cerr << "* Creates a vector of random integers " << std::endl;
+ std::cerr << "* Pushes the elements into the container" << std::endl;
+ std::cerr << "* Pops the elements from the container" << std::endl;
+ std::cerr << "* Repeats the above test a number of times "
+ << std::endl;
+
+ std::cerr << std::endl << std::endl;
+
+ std::cerr << "vn = minimum size of the vector" << std::endl;
+ std::cerr << "vs = step size of the vector" << std::endl;
+ std::cerr << "vm = maximum size of the vector" << std::endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join.cc
new file mode 100644
index 000000000..fe652241f
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_join.cc
@@ -0,0 +1,113 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_text_join_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/timing/join_test.hpp>
+#include <io/text_populate.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: priority_queue_text_join_timing_test <f_name> <vn> <vs> <vm>";
+ cerr << endl << endl;
+
+ cerr << "This test checks the performance of various priority_queueiative containers "
+ "using their join method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Pushes the elements into two containers" << endl;
+ cerr << "* Joins the two containers (and measures this time)" << endl;
+ cerr << "* Repeats the above test a number of times " << endl;
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef join_test<vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm);
+ {
+ typedef pq_common_types<std::string>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<std::string, true> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<std::string, false> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp
new file mode 100644
index 000000000..8ee65d154
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_text_modify_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/timing/modify_test.hpp>
+#include <io/text_populate.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+void
+set_test_parameters(bool& b);
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 100;
+ size_t vs = 100;
+ size_t vm = 1100;
+ bool modify_up;
+
+ set_test_parameters(modify_up);
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef modify_test<vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm, modify_up);
+ {
+ typedef pq_common_types<std::string>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<std::string, true> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<std::string, false> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: priority_queue_text_modify_timing_test <f_name> <vn> <vs> <vm> <modify_up>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various priority_queueiative containers "
+ "using their modify method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Pushes the elements into the container" << endl;
+ cerr << "* Modifies the words in the container. If modify_up == 't', then" << endl;
+ cerr << "* it modifies them to the largest word. If modify_up == 'f', then" << endl;
+ cerr << "* it modifies them to the smallest word." << endl;
+ cerr << "* Repeats the above test a number of times "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_down.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_down.cc
new file mode 100644
index 000000000..03ef831a0
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_down.cc
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "priority_queue_text_modify.hpp"
+
+void
+set_test_parameters(bool& b)
+{ b = false; }
+
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_up.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_up.cc
new file mode 100644
index 000000000..3331ee569
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_up.cc
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+#include "priority_queue_text_modify.hpp"
+
+void
+set_test_parameters(bool& b)
+{ b = true; }
+
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc
new file mode 100644
index 000000000..6470fef75
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_text_push_pop_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <iostream>
+#include <vector>
+#include <ext/typelist.h>
+#include <testsuite_allocator.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/mem_usage/pop_test.hpp>
+#include <io/text_populate.hpp>
+#include <native_type/native_priority_queue.hpp>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Memory (bytes)");
+ typedef __gnu_test::tracker_allocator<char> allocator_type;
+ typedef std::char_traits<char> traits_type;
+ typedef std::basic_string<char, traits_type, allocator_type> string_t;
+ typedef std::less<string_t> cmp_type;
+
+ typedef std::vector<std::pair<string_t, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef pop_test<vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm);
+ {
+ typedef pq_common_types<string_t, cmp_type, allocator_type>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<string_t, true, cmp_type,
+ allocator_type> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<string_t, false, cmp_type,
+ allocator_type> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: priority_queue_text_pop_mem_usage_test <f_name> <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various priority_queueiative containers "
+ "using their push method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Pushes the elements into the container, then pops until it's empty." << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push.cc
new file mode 100644
index 000000000..2c9c7e91e
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push.cc
@@ -0,0 +1,117 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_text_push_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/timing/push_test.hpp>
+#include <io/text_populate.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef push_test<vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm);
+ {
+ typedef pq_common_types<std::string>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<std::string, true> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<std::string, false> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: priority_queue_text_push_timing_test <f_name> <vn> <vs> <vm>"
+ << endl << endl;
+
+ cerr <<
+ "This test checks the performance of various priority_queue containers "
+ "using their push method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Pushes the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc
new file mode 100644
index 000000000..e39d6db01
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_text_push_pop_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+#include <performance/priority_queue/timing/push_pop_test.hpp>
+#include <io/text_populate.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef push_pop_test<vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm);
+ {
+ typedef pq_common_types<std::string>::performance_tl pq_tl_t;
+ pq_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_priority_queue<std::string, true> native_pq_t;
+ tst(native_pq_t());
+ }
+
+ {
+ typedef native_priority_queue<std::string, false> native_pq_t;
+ tst(native_pq_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: priority_queue_text_push_pop_timing_test "
+ "<f_name> <vn> <vs> <vm>" << endl << endl;
+
+ cerr << "This test checks the performance of various"
+ "priority_queue containers using their push method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Pushes the elements into the container, then pops until it's empty." << endl;
+ cerr << "* Repeats the above test a number of times) "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics.cc
new file mode 100644
index 000000000..5921cbf58
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_order_statistics.cc
@@ -0,0 +1,105 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_order_statistics_timing_test.cpp
+ * Contains test for order_statisticsing trees.
+ */
+
+#include <iostream>
+#include <vector>
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/tree_order_statistics_test.hpp>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ {
+ typedef tree_order_statistics_test< true> test_t;
+ test_t tst(vn, vs, vm);
+ typedef tree_common_types<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::tree_order_statistics_node_update>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef tree_order_statistics_test<false> test_t;
+ test_t tst(vn, vs, vm);
+ typedef native_set<int> native_set_t;
+ tst(native_set_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: tree_order_statistics_timing_test.out <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr << "This test checks the performance of order statistics"
+ " in tree based containers. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a tree" << endl;
+ cerr << "* Inserts integers into the tree" << endl;
+ cerr << "* Checks the order-statistics of each entry in the tree" << endl;
+ cerr << "* Repeats the above test some times"
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the tree" << endl;
+ cerr << "vs = step size of the tree" << endl;
+ cerr << "vm = maximum size of the tree" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join.cc
new file mode 100644
index 000000000..9f7e59fc2
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_split_join.cc
@@ -0,0 +1,107 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_split_join_timing_test.cpp
+ * Contains test for joining trees.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <testsuite_rng.h>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/tree_split_join_test.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ {
+ typedef tree_split_join_test<true> test_t;
+ test_t tst(vn, vs, vm);
+
+ typedef tree_common_types<int, __gnu_pbds::null_type>::performance_tl tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef tree_split_join_test<false> test_t;
+ test_t tst(vn, vs, vm);
+ typedef native_set<int> native_set_t;
+ tst(native_set_t());
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: tree_split_join_test.cpp <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr << "This test checks the performance of splitting joining"
+ "tree based containers. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a tree " << endl;
+ cerr << "* Inserts integers into the tree" << endl;
+ cerr << "* Splits half the tree into a different tree" << endl;
+ cerr << "* Joins the trees" << endl;
+ cerr << "* Repeats the above test a given number of times) "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "vn = minimum size of the tree" << endl;
+ cerr << "vs = step size of the tree" << endl;
+ cerr << "vm = maximum size of the tree" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert.cc
new file mode 100644
index 000000000..6296b10ba
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert.cc
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_text_insert_timing_test.cpp
+ * Contains test for finding text.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/insert_test.hpp>
+#include <io/text_populate.hpp>
+#include <hash_fn/string_hash_fn.hpp>
+#include <native_type/native_hash_map.hpp>
+#include <native_type/native_map.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef insert_test< vec_t::const_iterator> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, vn, vs, vm);
+ {
+ typedef trie_common_types<std::string, char>::performance_tl pat_trie_tl_t;
+ typedef tree_common_types<std::string, char>::performance_tl tree_tl_t;
+ typedef __gnu_cxx::typelist::append<pat_trie_tl_t, tree_tl_t>::type tl_t;
+ tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+
+ {
+ typedef native_map<std::string, char> native_map_t;
+ tst(native_map_t());
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: tree_text_insert_timing_test <f_name> <vn> <vs> <vm>" <<
+ endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their insert method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Repeats the above test a number of times) "
+ << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}
diff --git a/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find.cc b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find.cc
new file mode 100644
index 000000000..698781a9b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find.cc
@@ -0,0 +1,115 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_text_lor_find_timing_test.cpp
+ * Contains test for finding text with locality of reference.
+ */
+
+#include <ext/typelist.h>
+#include <performance/io/xml_formatter.hpp>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/assoc/common_type.hpp>
+#include <performance/assoc/timing/find_test.hpp>
+#include <io/text_populate.hpp>
+#include <native_type/native_map.hpp>
+#include <iostream>
+#include <vector>
+
+void
+usage();
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+
+ std::string f_name = "thirty_years_among_the_dead_preproc.txt";
+ size_t vn = 200;
+ size_t vs = 200;
+ size_t vm = 2100;
+
+ try
+ {
+ xml_test_performance_formatter fmt("Size", "Average time (sec.)");
+
+ typedef std::vector<std::pair<std::string, char> > vec_t;
+ vec_t a_v(vm);
+ text_populate(f_name, a_v);
+
+ typedef find_test<vec_t::const_iterator, true> test_t;
+ vec_t::const_iterator b = a_v.begin();
+ test_t tst(b, b, vn, vs, vm, vn, vs, vm);
+ {
+ typedef native_map<std::string, char> native_set_t;
+ tst(native_set_t());
+ }
+
+ {
+ typedef tree_common_types<std::string, char>::performance_tl tree_tl_t;
+ tree_tl_t tl;
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed" << std::endl;
+ return -1;
+ }
+ return 0;
+}
+
+void
+usage()
+{
+ using namespace std;
+ cerr << "usage: tree_text_lor_find_performance_test <f_name> <vn> <vs> <vm>"
+ << endl << endl;
+
+ cerr <<
+ "This test checks the performance of various associative containers "
+ "using their find method. " << endl;
+ cerr << "Specifically, it does the following:" << endl;
+ cerr << "* Creates a vector of text words " << endl;
+ cerr << "* Inserts the elements into the container" << endl;
+ cerr << "* Performs a sequence of find operations. At each iteration, "
+ "it finds, for each word in the vector, its entry in the "
+ "container, using the find method" << endl;
+ cerr << "* Repeats the above test a number of times" << endl;
+
+ cerr << endl << endl;
+
+ cerr << "f_name = file name containing the text words. "
+ "Each line should contain one word." << endl;
+ cerr << "vn = minimum size of the vector" << endl;
+ cerr << "vs = step size of the vector" << endl;
+ cerr << "vm = maximum size of the vector" << endl;
+}