From 9f9900dbb6fe19fad02a53df9efecae35bd65976 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 3 Oct 2006 17:01:57 +0000 Subject: [PATCH] testsuite_allocator.h (allocation_tracker): To tracker_allocator_counter. 2006-10-03 Benjamin Kosnik * testsuite/util/testsuite_allocator.h (allocation_tracker): To tracker_allocator_counter. (allocation_tracker::allocationTotal): To get_allocation_count. (allocation_tracker::deallocationTotal): To get_deallocation_count. (allocation_tracker::constructCount): To get_construct_count. (allocation_tracker::destructCount): To get_destruct_count. (allocation_tracker::resetCounts): To reset. (tracker_alloc): To tracker_allocator. * testsuite/util/performance/mem: Remove. * testsuite/util/performance/mem/mem_track_allocator_base.hpp: Remove. * testsuite/util/performance/mem/mem_track_allocator.hpp: Remove. * testsuite/27_io/basic_stringbuf/4.cc: Adjust for new names or includes. * testsuite/ext/hash_set/check_construct_destroy.cc: Same. * testsuite/ext/slist/check_construct_destroy.cc: Same. * testsuite/performance/ext/pb_ds/ hash_random_int_erase_mem_usage.cc: Same. * testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp * testsuite/performance/ext/pb_ds/ priority_queue_text_pop_mem_usage.cc: Same. * testsuite/23_containers/vector/capacity/2.cc: Same. * testsuite/23_containers/vector/cons/4.cc: Same. * testsuite/23_containers/vector/check_construct_destroy.cc: Same. * testsuite/23_containers/deque/cons/2.cc: Same. * testsuite/23_containers/deque/check_construct_destroy.cc: Same. * testsuite/23_containers/list/check_construct_destroy.cc: Same. * testsuite/23_containers/set/check_construct_destroy.cc: Same. * testsuite/util/testsuite_allocator.h * testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp * testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp * testsuite/util/performance/assoc/mem_usage/erase_test.hpp * testsuite/util/testsuite_allocator.cc: Same. From-SVN: r117408 --- libstdc++-v3/ChangeLog | 35 ++++ .../deque/check_construct_destroy.cc | 12 +- .../testsuite/23_containers/deque/cons/2.cc | 16 +- .../list/check_construct_destroy.cc | 12 +- .../set/check_construct_destroy.cc | 12 +- .../23_containers/vector/capacity/2.cc | 16 +- .../vector/check_construct_destroy.cc | 12 +- .../testsuite/23_containers/vector/cons/4.cc | 130 ++++++------ .../testsuite/27_io/basic_stringbuf/4.cc | 2 +- .../ext/hash_set/check_construct_destroy.cc | 12 +- .../ext/slist/check_construct_destroy.cc | 12 +- .../pb_ds/hash_random_int_erase_mem_usage.cc | 4 +- .../pb_ds/multimap_text_insert_mem_usage.hpp | 8 +- .../priority_queue_text_pop_mem_usage.cc | 19 +- .../assoc/mem_usage/erase_test.hpp | 10 +- .../assoc/mem_usage/multimap_insert_test.hpp | 16 +- .../performance/mem/mem_track_allocator.hpp | 189 ------------------ .../mem/mem_track_allocator_base.hpp | 116 ----------- .../priority_queue/mem_usage/pop_test.hpp | 10 +- .../testsuite/util/testsuite_allocator.cc | 41 ++-- .../testsuite/util/testsuite_allocator.h | 66 +++--- 21 files changed, 244 insertions(+), 506 deletions(-) delete mode 100644 libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator.hpp delete mode 100644 libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator_base.hpp diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 52f6cbdd349..ccfeb4cc1f8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,38 @@ +2006-10-03 Benjamin Kosnik + + * testsuite/util/testsuite_allocator.h (allocation_tracker): To + tracker_allocator_counter. + (allocation_tracker::allocationTotal): To get_allocation_count. + (allocation_tracker::deallocationTotal): To get_deallocation_count. + (allocation_tracker::constructCount): To get_construct_count. + (allocation_tracker::destructCount): To get_destruct_count. + (allocation_tracker::resetCounts): To reset. + (tracker_alloc): To tracker_allocator. + * testsuite/util/performance/mem: Remove. + * testsuite/util/performance/mem/mem_track_allocator_base.hpp: Remove. + * testsuite/util/performance/mem/mem_track_allocator.hpp: Remove. + * testsuite/27_io/basic_stringbuf/4.cc: Adjust for new names + or includes. + * testsuite/ext/hash_set/check_construct_destroy.cc: Same. + * testsuite/ext/slist/check_construct_destroy.cc: Same. + * testsuite/performance/ext/pb_ds/ + hash_random_int_erase_mem_usage.cc: Same. + * testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp + * testsuite/performance/ext/pb_ds/ + priority_queue_text_pop_mem_usage.cc: Same. + * testsuite/23_containers/vector/capacity/2.cc: Same. + * testsuite/23_containers/vector/cons/4.cc: Same. + * testsuite/23_containers/vector/check_construct_destroy.cc: Same. + * testsuite/23_containers/deque/cons/2.cc: Same. + * testsuite/23_containers/deque/check_construct_destroy.cc: Same. + * testsuite/23_containers/list/check_construct_destroy.cc: Same. + * testsuite/23_containers/set/check_construct_destroy.cc: Same. + * testsuite/util/testsuite_allocator.h + * testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp + * testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp + * testsuite/util/performance/assoc/mem_usage/erase_test.hpp + * testsuite/util/testsuite_allocator.cc: Same. + 2006-10-03 Benjamin Kosnik * testsuite/util/native_type/priority_queue/native_pq_tag.hpp: Remove. diff --git a/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc index eb111c8fb2b..7ddebdcec3d 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/check_construct_destroy.cc @@ -34,11 +34,11 @@ using namespace __gnu_test; int main() { - typedef std::deque > Container; + typedef std::deque > Container; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; bool ok = true; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c; ok = check_construct_destroy("empty container", 0, 0) && ok; @@ -46,7 +46,7 @@ int main() ok = check_construct_destroy("empty container", 0, 0) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); ok = check_construct_destroy("Construct from range", 10, 0) && ok; @@ -55,7 +55,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin(), arr10[0]); ok = check_construct_destroy("Insert element", 1, 0) && ok; } @@ -63,7 +63,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin() + 5, arr10, arr10+3); ok = check_construct_destroy("Insert short range", 3, 0) && ok; } @@ -71,7 +71,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin() + 7, arr10, arr10+10); ok = check_construct_destroy("Insert long range", 10, 0) && ok; } diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc index cafdbb203ec..848e61a2f18 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/2.cc @@ -27,8 +27,8 @@ #include using __gnu_test::copy_tracker; -using __gnu_test::allocation_tracker; -using __gnu_test::tracker_alloc; +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; using __gnu_test::copy_constructor; using __gnu_test::assignment_operator; using __gnu_test::counter; @@ -445,11 +445,11 @@ test_default_ctor_exception_safety() { // setup typedef copy_tracker T; - typedef std::deque > X; + typedef std::deque > X; T::reset(); copy_constructor::throw_on(3); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // test try @@ -462,7 +462,7 @@ test_default_ctor_exception_safety() } // assert postconditions - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown } @@ -473,9 +473,9 @@ test_copy_ctor_exception_safety() { // setup typedef copy_tracker T; - typedef std::deque > X; + typedef std::deque > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); T::reset(); @@ -494,7 +494,7 @@ test_copy_ctor_exception_safety() } // assert postconditions - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown } diff --git a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc index ed6832ce0ff..e3e1db80cd4 100644 --- a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc +++ b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc @@ -35,11 +35,11 @@ using namespace __gnu_test; int main() { - typedef std::list > Container; + typedef std::list > Container; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; bool ok = true; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c; ok = check_construct_destroy("empty container", 0, 0) && ok; @@ -47,7 +47,7 @@ int main() ok = check_construct_destroy("empty container", 0, 0) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); ok = check_construct_destroy("Construct from range", 10, 0) && ok; @@ -56,7 +56,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin(), arr10[0]); ok = check_construct_destroy("Insert element", 1, 0) && ok; } @@ -64,7 +64,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); Container::iterator i5 = c.begin(); std::advance(i5, 5); c.insert(i5, arr10, arr10+3); @@ -74,7 +74,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); Container::iterator i7 = c.begin(); std::advance(i7, 5); c.insert(i7, arr10, arr10+10); diff --git a/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc index db3f6c8d8bc..85ea5fd6f00 100644 --- a/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc +++ b/libstdc++-v3/testsuite/23_containers/set/check_construct_destroy.cc @@ -36,12 +36,12 @@ using namespace __gnu_test; int main() { - typedef std::set, tracker_alloc > Container; + typedef std::set, tracker_allocator > Container; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; const int arr10a[10] = { 31, 23, 82, 46, 13, 17, 30, 71, 22, 51 }; bool ok = true; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c; ok = check_construct_destroy("empty container", 0, 0) && ok; @@ -49,7 +49,7 @@ int main() ok = check_construct_destroy("empty container", 0, 0) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); ok = check_construct_destroy("Construct from range", 10, 0) && ok; @@ -58,7 +58,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(arr10a[0]); ok = check_construct_destroy("Insert element", 1, 0) && ok; } @@ -66,7 +66,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(arr10a, arr10a+3); ok = check_construct_destroy("Insert short range", 3, 0) && ok; } @@ -74,7 +74,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(arr10a, arr10a+10); ok = check_construct_destroy("Insert long range", 10, 0) && ok; } diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc index f61ba572ccf..1fc84c144fc 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/2.cc @@ -27,8 +27,8 @@ #include using __gnu_test::copy_tracker; -using __gnu_test::allocation_tracker; -using __gnu_test::tracker_alloc; +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; using __gnu_test::copy_constructor; using __gnu_test::assignment_operator; using __gnu_test::destructor; @@ -39,9 +39,9 @@ test_reserve() { bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(3); const X::size_type old_size = a.size(); @@ -59,7 +59,7 @@ test_reserve() VERIFY(destructor::count() <= old_size); } // check for memory leaks - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); } // Verifies that reserve() with reallocation offers the strong @@ -69,9 +69,9 @@ test_reserve_exception_guarantee() { bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); const X::size_type old_size __attribute__((unused)) = a.size(); @@ -92,7 +92,7 @@ test_reserve_exception_guarantee() VERIFY(old_capacity == a.capacity()); VERIFY(copy_constructor::count() == destructor::count()+1); } - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc index 7e6c24c8b22..4c741984ca6 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc @@ -34,11 +34,11 @@ using namespace __gnu_test; int main() { - typedef std::vector > Container; + typedef std::vector > Container; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; bool ok = true; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c; ok = check_construct_destroy("empty container", 0, 0) && ok; @@ -46,7 +46,7 @@ int main() ok = check_construct_destroy("empty container", 0, 0) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); ok = check_construct_destroy("Construct from range", 10, 0) && ok; @@ -56,7 +56,7 @@ int main() { Container c(arr10, arr10 + 10); c.reserve(100); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin(), arr10[0]); ok = check_construct_destroy("Insert element", 1, 0) && ok; } @@ -65,7 +65,7 @@ int main() { Container c(arr10, arr10 + 10); c.reserve(100); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin() + 5, arr10, arr10+3); ok = check_construct_destroy("Insert short range", 3, 0) && ok; } @@ -74,7 +74,7 @@ int main() { Container c(arr10, arr10 + 10); c.reserve(100); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin() + 7, arr10, arr10+10); ok = check_construct_destroy("Insert long range", 10, 0) && ok; } diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc index 66d21503f0a..a8924f2b1a6 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/4.cc @@ -26,8 +26,8 @@ #include using __gnu_test::copy_tracker; -using __gnu_test::allocation_tracker; -using __gnu_test::tracker_alloc; +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; using __gnu_test::copy_constructor; using __gnu_test::assignment_operator; @@ -42,11 +42,11 @@ test_default_ctor_exception_gurantee() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; copy_tracker::reset(); copy_constructor::throw_on(3); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // run test try @@ -59,7 +59,7 @@ test_default_ctor_exception_gurantee() } // assert postconditions - VERIFY( allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal() ); + VERIFY( tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count() ); // teardown } @@ -74,9 +74,9 @@ test_copy_ctor_exception_gurantee() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); copy_tracker::reset(); @@ -94,11 +94,11 @@ test_copy_ctor_exception_gurantee() } // assert postconditions - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } // operator=() @@ -113,12 +113,12 @@ test_assignment_operator_1() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X r(9); X a(r.size() - 2); copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // preconditions VERIFY(r.size() > a.size()); @@ -128,11 +128,11 @@ test_assignment_operator_1() // assert postconditions VERIFY(r == a); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -141,13 +141,13 @@ test_assignment_operator_2() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X r(1); r.reserve(17); X a(r.size() + 7); copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // preconditions VERIFY(r.size() < a.size()); @@ -158,11 +158,11 @@ test_assignment_operator_2() // assert postconditions VERIFY(r == a); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -171,9 +171,9 @@ test_assignment_operator_3() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X r(1); X a(r.capacity() + 7); @@ -188,11 +188,11 @@ test_assignment_operator_3() // assert postconditions VERIFY(r == a); } - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -201,9 +201,9 @@ test_assignment_operator_3_exception_guarantee() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X r(1); X a(r.capacity() + 7); @@ -225,11 +225,11 @@ test_assignment_operator_3_exception_guarantee() } // assert postconditions - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } // fill assign() @@ -246,7 +246,7 @@ test_fill_assign_1() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X a(7); X::size_type old_size = a.size(); @@ -254,18 +254,18 @@ test_fill_assign_1() const T t; copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // run test a.assign(new_size, t); // assert postconditions VERIFY(a.size() == new_size); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -274,7 +274,7 @@ test_fill_assign_2() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X a(7); a.reserve(11); @@ -284,7 +284,7 @@ test_fill_assign_2() const T t; copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // assert preconditions VERIFY(old_size < new_size); @@ -295,11 +295,11 @@ test_fill_assign_2() // assert postconditions VERIFY(a.size() == new_size); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -308,9 +308,9 @@ test_fill_assign_3() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); X::size_type old_capacity = a.capacity(); @@ -329,12 +329,12 @@ test_fill_assign_3() VERIFY(a.size() == new_size); } - VERIFY(allocation_tracker::allocationTotal() > 0); - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -343,9 +343,9 @@ test_fill_assign_3_exception_guarantee() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); X::size_type old_size = a.size(); @@ -374,12 +374,12 @@ test_fill_assign_3_exception_guarantee() VERIFY(a.capacity() == old_capacity); } - VERIFY(allocation_tracker::allocationTotal() > 0); - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -388,7 +388,7 @@ test_fill_assign_4() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X a(7); X::size_type old_size = a.size(); @@ -396,18 +396,18 @@ test_fill_assign_4() X::size_type new_value = 117; copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // run test a.assign(new_size, new_value); // assert postconditions VERIFY(a.size() == new_size); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } // range assign() @@ -432,13 +432,13 @@ test_range_assign_2() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X a(7); X b(3); copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // assert preconditions VERIFY(b.size() < a.capacity()); @@ -449,11 +449,11 @@ test_range_assign_2() // assert postconditions VERIFY(a.size() == b.size()); VERIFY(a == b); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -462,14 +462,14 @@ test_range_assign_3() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; X a(7); a.reserve(a.size() + 7); X b(a.size() + 3); copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); // assert preconditions VERIFY(a.size() < b.size()); @@ -481,11 +481,11 @@ test_range_assign_3() // assert postconditions VERIFY(a.size() == b.size()); VERIFY(a == b); - VERIFY(allocation_tracker::allocationTotal() == 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == 0); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -494,9 +494,9 @@ test_range_assign_4() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); X b(a.capacity() + 7); @@ -513,12 +513,12 @@ test_range_assign_4() VERIFY(a.size() == b.size()); VERIFY(a == b); } - VERIFY(allocation_tracker::allocationTotal() > 0); - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } void @@ -527,9 +527,9 @@ test_range_assign_4_exception_guarantee() // setup bool test __attribute__((unused)) = true; typedef copy_tracker T; - typedef std::vector > X; + typedef std::vector > X; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { X a(7); X b(a.capacity() + 7); @@ -552,12 +552,12 @@ test_range_assign_4_exception_guarantee() } // assert postconditions - VERIFY(allocation_tracker::allocationTotal() > 0); - VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); + VERIFY(tracker_allocator_counter::get_allocation_count() > 0); + VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count()); // teardown copy_tracker::reset(); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); } diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc index d9aa34d1e92..d4412cdb9f4 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/4.cc @@ -31,7 +31,7 @@ namespace std { using __gnu_test::pod_char; - typedef __gnu_test::tracker_alloc alloc_type; + typedef __gnu_test::tracker_allocator alloc_type; template class basic_stringbuf, alloc_type>; } // test diff --git a/libstdc++-v3/testsuite/ext/hash_set/check_construct_destroy.cc b/libstdc++-v3/testsuite/ext/hash_set/check_construct_destroy.cc index 1081e53a344..4f03e49af5c 100644 --- a/libstdc++-v3/testsuite/ext/hash_set/check_construct_destroy.cc +++ b/libstdc++-v3/testsuite/ext/hash_set/check_construct_destroy.cc @@ -37,7 +37,7 @@ using namespace __gnu_test; int main() { typedef __gnu_cxx::hash_set, std::equal_to, - tracker_alloc > + tracker_allocator > Container; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; @@ -46,7 +46,7 @@ int main() int buckets; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c; buckets = c.bucket_count(); @@ -55,14 +55,14 @@ int main() ok = check_construct_destroy("empty container", buckets, buckets) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); ok = check_construct_destroy("Construct from range", buckets+10, 0) && ok; } ok = check_construct_destroy("Construct from range", buckets+10, buckets+10) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); c.insert(arr10a[0]); @@ -70,7 +70,7 @@ int main() } ok = check_construct_destroy("Insert element", buckets+11, buckets+11) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); c.insert(arr10a, arr10a+3); @@ -78,7 +78,7 @@ int main() } ok = check_construct_destroy("Insert short range", buckets+13, buckets+13) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); c.insert(arr10a, arr10a+10); diff --git a/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc b/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc index 97f0af63646..ecb9dd6ecab 100644 --- a/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc +++ b/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc @@ -35,11 +35,11 @@ using namespace __gnu_test; int main() { - typedef __gnu_cxx::slist > Container; + typedef __gnu_cxx::slist > Container; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; bool ok = true; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c; ok = check_construct_destroy("empty container", 0, 0) && ok; @@ -47,7 +47,7 @@ int main() ok = check_construct_destroy("empty container", 0, 0) && ok; - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); { Container c(arr10, arr10 + 10); ok = check_construct_destroy("Construct from range", 10, 0) && ok; @@ -56,7 +56,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); c.insert(c.begin(), arr10[0]); ok = check_construct_destroy("Insert element", 1, 0) && ok; } @@ -64,7 +64,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); Container::iterator i5 = c.begin(); std::advance(i5, 5); c.insert(i5, arr10, arr10+3); @@ -74,7 +74,7 @@ int main() { Container c(arr10, arr10 + 10); - allocation_tracker::resetCounts(); + tracker_allocator_counter::reset(); Container::iterator i7 = c.begin(); std::advance(i7, 5); c.insert(i7, arr10, arr10+10); diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc index b22b342ebdd..27a7ff87903 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/hash_random_int_erase_mem_usage.cc @@ -45,12 +45,12 @@ */ #include +#include #include #include #include #include #include -#include #include #include #include @@ -85,7 +85,7 @@ main(int argc, char* a_p_argv[]) vec_t::const_iterator b = a_v.begin(); erase_test tst(b, vn, vs, vm); - typedef mem_track_allocator alloc_t; + typedef __gnu_test::tracker_allocator alloc_t; { typedef hash_common_types, alloc_t>::performance_tl tl_t; diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp index 5a5f3ea6500..5bfa42b3b6d 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem_usage.hpp @@ -44,7 +44,10 @@ * Contains test for inserting text words. */ +#include +#include #include +#include #include #include #include @@ -54,10 +57,7 @@ #include #include #include -#include #include -#include -#include void usage(); @@ -86,7 +86,7 @@ main(int argc, char* a_p_argv[]) init_vec_t a_v_init(prm); distinct_text_populate(f_name, a_v_init); - typedef mem_track_allocator alloc_t; + typedef __gnu_test::tracker_allocator alloc_t; typedef std::basic_string, alloc_t> string_t; typedef std::vector > vec_t; vec_t a_v; diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc index 681ad71d6eb..3185e9b1ff0 100644 --- a/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc +++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem_usage.cc @@ -44,16 +44,16 @@ * Contains test for finding text. */ +#include +#include #include +#include #include #include #include #include #include #include -#include -#include -#include void usage(); @@ -70,10 +70,11 @@ main(int argc, char* a_p_argv[]) try { xml_test_performance_formatter fmt("Size", "Memory (bytes)"); + typedef __gnu_test::tracker_allocator callocator_type; + typedef __gnu_test::tracker_allocator sallocator_type; + typedef std::basic_string, callocator_type> string_t; - typedef std::basic_string, mem_track_allocator > string_t; - - typedef std::vector > vec_t; + typedef std::vector > vec_t; vec_t a_v(vm); text_populate(f_name, a_v); @@ -81,18 +82,18 @@ main(int argc, char* a_p_argv[]) vec_t::const_iterator b = a_v.begin(); test_t tst(b, vn, vs, vm); { - typedef pq_common_types, mem_track_allocator >::performance_tl pq_tl_t; + typedef pq_common_types, callocator_type>::performance_tl pq_tl_t; pq_tl_t tl; __gnu_cxx::typelist::apply(tst, tl); } { - typedef native_priority_queue, mem_track_allocator > native_pq_t; + typedef native_priority_queue, sallocator_type> native_pq_t; tst(native_pq_t()); } { - typedef native_priority_queue, mem_track_allocator > native_pq_t; + typedef native_priority_queue, sallocator_type> native_pq_t; tst(native_pq_t()); } } diff --git a/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp index 82f5634f14b..c95d9f7917a 100644 --- a/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp +++ b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp @@ -47,11 +47,11 @@ #ifndef PB_DS_ERASE_TEST_HPP #define PB_DS_ERASE_TEST_HPP +#include +#include #include -#include #include #include -#include namespace pb_ds { @@ -96,14 +96,14 @@ namespace pb_ds It ins_it_e = m_ins_b; std::advance(ins_it_e, ins_size); - mem_track_allocator alloc; - const size_t init_mem = alloc.get_total(); + __gnu_test::tracker_allocator alloc; + const size_t init_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); Cntnr cntnr(ins_it_b, ins_it_e); while (cntnr.size() > 1) cntnr.erase(*cntnr.begin()); - const size_t final_mem = alloc.get_total(); + const size_t final_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); assert(final_mem > init_mem); const size_t delta_mem = final_mem - init_mem; res_set_fmt.add_res(ins_size, static_cast(delta_mem)); diff --git a/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp index 85ea8a6903f..92e98ce786a 100644 --- a/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp +++ b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp @@ -47,11 +47,11 @@ #ifndef PB_DS_MULTIMAP_INSERT_TEST_HPP #define PB_DS_MULTIMAP_INSERT_TEST_HPP +#include #include -#include +#include #include #include -#include namespace pb_ds { @@ -116,12 +116,12 @@ namespace pb_ds multimap_insert_test:: insert(Cntnr, It ins_it_b, It ins_it_e, pb_ds::detail::true_type) { - mem_track_allocator alloc; - const size_t init_mem = alloc.get_total(); + __gnu_test::tracker_allocator alloc; + const size_t init_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); Cntnr cntnr; for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it) cntnr.insert((typename Cntnr::const_reference)(*ins_it)); - const size_t final_mem = alloc.get_total(); + const size_t final_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); assert(final_mem > init_mem); return (final_mem - init_mem); } @@ -132,12 +132,12 @@ namespace pb_ds multimap_insert_test:: insert(Cntnr, It ins_it_b, It ins_it_e, pb_ds::detail::false_type) { - mem_track_allocator alloc; - const size_t init_mem = alloc.get_total(); + __gnu_test::tracker_allocator alloc; + const size_t init_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); Cntnr cntnr; for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it) cntnr[ins_it->first].insert(ins_it->second); - const size_t final_mem = alloc.get_total(); + const size_t final_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); assert(final_mem > init_mem); return (final_mem - init_mem); } diff --git a/libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator.hpp b/libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator.hpp deleted file mode 100644 index d119e95c2cd..00000000000 --- a/libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator.hpp +++ /dev/null @@ -1,189 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 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 2, 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 COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free -// software library without restriction. Specifically, if other files -// instantiate templates or use macros or inline functions from this -// file, or you compile this file and link it with other files to -// produce an executable, this file does not by itself cause the -// resulting executable to be covered by the GNU General Public -// License. This exception does not however invalidate any other -// reasons why the executable file might be covered by the GNU General -// Public License. - -// 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 mem_track_allocator.hpp - * Contains a memory-tracking allocator used for tests. - */ - -#ifndef PB_DS_MEM_TRACK_ALLOCATOR_HPP -#define PB_DS_MEM_TRACK_ALLOCATOR_HPP - -#include - -namespace pb_ds -{ - - namespace test - { - -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - mem_track_allocator< \ - T> - - template - class mem_track_allocator : public detail::mem_track_allocator_base - { - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T value_type; - - template - struct rebind - { - typedef mem_track_allocator other; - }; - - mem_track_allocator() throw(); - - mem_track_allocator(const PB_DS_CLASS_C_DEC& ) throw(); - - template - mem_track_allocator(const mem_track_allocator& ) throw(); - - ~mem_track_allocator() throw(); - - size_type - max_size() const throw(); - - pointer - allocate(size_type num, std::allocator::const_pointer hint = 0); - - void - construct(pointer p, const T& r_val); - - void - destroy(pointer p); - - void - deallocate(pointer p, size_type num); - }; - - PB_DS_CLASS_T_DEC - bool - operator==(const PB_DS_CLASS_C_DEC& , const PB_DS_CLASS_C_DEC& ) - { - return true; - } - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - mem_track_allocator() throw() - { } - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - mem_track_allocator(const PB_DS_CLASS_C_DEC& ) throw() - { } - - PB_DS_CLASS_T_DEC - template - PB_DS_CLASS_C_DEC:: - mem_track_allocator(const mem_track_allocator& ) throw() - { } - - PB_DS_CLASS_T_DEC - PB_DS_CLASS_C_DEC:: - ~mem_track_allocator() throw() - { } - - PB_DS_CLASS_T_DEC - typename PB_DS_CLASS_C_DEC::size_type - PB_DS_CLASS_C_DEC:: - max_size() const throw() - { - return (std::allocator().max_size()); - } - - PB_DS_CLASS_T_DEC - typename PB_DS_CLASS_C_DEC::pointer - PB_DS_CLASS_C_DEC:: - allocate(size_type num, std::allocator::const_pointer hint/*= 0*/) - { - T* const a_t = std::allocator().allocate(num, hint); - - inc(sizeof(T)* num); - - return (a_t); - } - - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - construct(pointer p, const T& r_val) - { - return (std::allocator().construct(p, r_val)); - } - - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - destroy(pointer p) - { - std::allocator().destroy(p); - } - - PB_DS_CLASS_T_DEC - void - PB_DS_CLASS_C_DEC:: - deallocate(pointer p, size_type num) - { - std::allocator().deallocate(p, num); - - dec(sizeof(T)* num); - } - -#undef PB_DS_CLASS_T_DEC -#undef PB_DS_CLASS_C_DEC - - } // namespace test - -} // namespace pb_ds - -#endif // #ifndef PB_DS_MEM_TRACK_ALLOCATOR_HPP diff --git a/libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator_base.hpp b/libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator_base.hpp deleted file mode 100644 index 97d831a755e..00000000000 --- a/libstdc++-v3/testsuite/util/performance/mem/mem_track_allocator_base.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2005, 2006 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 2, 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 COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free -// software library without restriction. Specifically, if other files -// instantiate templates or use macros or inline functions from this -// file, or you compile this file and link it with other files to -// produce an executable, this file does not by itself cause the -// resulting executable to be covered by the GNU General Public -// License. This exception does not however invalidate any other -// reasons why the executable file might be covered by the GNU General -// Public License. - -// 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 mem_track_allocator_base.hpp - * Contains a base for a memory-tracking allocator used for tests. - */ - -#ifndef PB_DS_MEM_TRACK_ALLOCATOR_BASE_HPP -#define PB_DS_MEM_TRACK_ALLOCATOR_BASE_HPP - -#include - -namespace pb_ds -{ - - namespace test - { - - namespace detail - { - - struct total_holder - { - total_holder() : m_total(0) - { } - - size_t m_total; - }; - - class mem_track_allocator_base - { - public: - static void - inc(size_t size); - - static void - dec(size_t size); - - static size_t - get_total(); - - private: - static total_holder s_total_holder; - }; - - total_holder mem_track_allocator_base::s_total_holder; - - void - mem_track_allocator_base:: - inc(size_t size) - { - s_total_holder.m_total += size; - } - - void - mem_track_allocator_base:: - dec(size_t size) - { - assert(s_total_holder.m_total >= size); - - s_total_holder.m_total -= size; - } - - size_t - mem_track_allocator_base:: - get_total() - { - return (s_total_holder.m_total); - } - - } // namespace detail - - } // namespace test - -} // namespace pb_ds - -#endif // #ifndef PB_DS_MEM_TRACK_ALLOCATOR_BASE_HPP diff --git a/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp b/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp index d6d6464d774..0ca0fdc6035 100644 --- a/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp +++ b/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp @@ -47,11 +47,11 @@ #ifndef PB_DS_POP_TEST_HPP #define PB_DS_POP_TEST_HPP +#include +#include #include -#include #include #include -#include namespace pb_ds { @@ -95,9 +95,9 @@ namespace pb_ds It ins_it_e = m_ins_b; std::advance(ins_it_e, ins_size); - mem_track_allocator alloc; + __gnu_test::tracker_allocator alloc; - const size_t init_mem = alloc.get_total(); + const size_t init_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); Cntnr cntnr; for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it) cntnr.push(ins_it->first); @@ -105,7 +105,7 @@ namespace pb_ds while (cntnr.size() > 1) cntnr.pop(); - const size_t final_mem = alloc.get_total(); + const size_t final_mem = alloc.get_allocation_count() - alloc.get_deallocation_count(); assert(final_mem > init_mem); const size_t delta_mem = final_mem - init_mem; res_set_fmt.add_res(ins_size, static_cast(delta_mem)); diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.cc b/libstdc++-v3/testsuite/util/testsuite_allocator.cc index 66968720555..fdaa647e6fd 100644 --- a/libstdc++-v3/testsuite/util/testsuite_allocator.cc +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.cc @@ -33,28 +33,33 @@ namespace __gnu_test { - allocation_tracker::size_type allocation_tracker::allocationTotal_ = 0; - allocation_tracker::size_type allocation_tracker::deallocationTotal_ = 0; - int allocation_tracker::constructCount_ = 0; - int allocation_tracker::destructCount_ = 0; + typedef tracker_allocator_counter counter_type; + + counter_type::size_type + counter_type::allocationCount_ = 0; + + counter_type::size_type + counter_type::deallocationCount_ = 0; + + int counter_type::constructCount_ = 0; + int counter_type::destructCount_ = 0; bool check_construct_destroy(const char* tag, int expected_c, int expected_d) { - if (allocation_tracker::constructCount() == expected_c && - allocation_tracker::destructCount() == expected_d) - return true; - - else { - std::cerr << tag << ": " - << " construct = " << allocation_tracker::constructCount() - << " (should be " << expected_c << ")," - << " destroy = " << allocation_tracker::destructCount() - << " (should be " << expected_d << ")" - << std::endl; - return false; - } + bool ret = true; + if (counter_type::get_construct_count() != expected_c + || counter_type::get_destruct_count() != expected_d) + { + std::cerr << tag << ": " + << " construct = " << counter_type::get_construct_count() + << " (should be " << expected_c << ")," + << " destroy = " << counter_type::get_destruct_count() + << " (should be " << expected_d << ")" + << std::endl; + ret = false; + } + return ret; } - }; // namespace __cxx_test diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h index 7c5f5723d12..51e4cf350e9 100644 --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h @@ -36,7 +36,6 @@ #define _GLIBCXX_TESTSUITE_ALLOCATOR_H #include -#include #include #include @@ -48,7 +47,7 @@ namespace namespace __gnu_test { - class allocation_tracker + class tracker_allocator_counter { public: typedef std::size_t size_type; @@ -56,7 +55,7 @@ namespace __gnu_test static void* allocate(size_type blocksize) { - allocationTotal_ += blocksize; + allocationCount_ += blocksize; return ::operator new(blocksize); } @@ -70,43 +69,46 @@ namespace __gnu_test deallocate(void* p, size_type blocksize) { ::operator delete(p); - deallocationTotal_ += blocksize; + deallocationCount_ += blocksize; } static size_type - allocationTotal() { return allocationTotal_; } + get_allocation_count() { return allocationCount_; } static size_type - deallocationTotal() { return deallocationTotal_; } + get_deallocation_count() { return deallocationCount_; } static int - constructCount() { return constructCount_; } + get_construct_count() { return constructCount_; } static int - destructCount() { return destructCount_; } + get_destruct_count() { return destructCount_; } static void - resetCounts() + reset() { - allocationTotal_ = 0; - deallocationTotal_ = 0; + allocationCount_ = 0; + deallocationCount_ = 0; constructCount_ = 0; - destructCount_ = 0; + destructCount_ = 0; } private: - static size_type allocationTotal_; - static size_type deallocationTotal_; + static size_type allocationCount_; + static size_type deallocationCount_; static int constructCount_; static int destructCount_; }; // A simple basic allocator that just forwards to the - // allocation_tracker to fulfill memory requests. This class is - // templated on the target object type, but tracker isn't. + // tracker_allocator_counter to fulfill memory requests. This class + // is templated on the target object type, but tracker isn't. template - class tracker_alloc + class tracker_allocator { + private: + typedef tracker_allocator_counter counter_type; + public: typedef T value_type; typedef T* pointer; @@ -116,7 +118,7 @@ namespace __gnu_test typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - template struct rebind { typedef tracker_alloc other; }; + template struct rebind { typedef tracker_allocator other; }; pointer address(reference value) const @@ -126,56 +128,56 @@ namespace __gnu_test address(const_reference value) const { return &value; } - tracker_alloc() throw() + tracker_allocator() throw() { } - tracker_alloc(const tracker_alloc&) throw() + tracker_allocator(const tracker_allocator&) throw() { } template - tracker_alloc(const tracker_alloc&) throw() + tracker_allocator(const tracker_allocator&) throw() { } - ~tracker_alloc() throw() + ~tracker_allocator() throw() { } size_type max_size() const throw() - { return std::numeric_limits::max() / sizeof(T); } + { return size_type(-1) / sizeof(T); } pointer allocate(size_type n, const void* = 0) - { - return static_cast(allocation_tracker::allocate(n * sizeof(T))); - } + { return static_cast(counter_type::allocate(n * sizeof(T))); } void construct(pointer p, const T& value) { new (p) T(value); - allocation_tracker::construct(); + counter_type::construct(); } void destroy(pointer p) { p->~T(); - allocation_tracker::destroy(); + counter_type::destroy(); } void deallocate(pointer p, size_type num) - { allocation_tracker::deallocate(p, num * sizeof(T)); } + { counter_type::deallocate(p, num * sizeof(T)); } }; template bool - operator==(const tracker_alloc&, const tracker_alloc&) throw() + operator==(const tracker_allocator&, + const tracker_allocator&) throw() { return true; } template bool - operator!=(const tracker_alloc&, const tracker_alloc&) throw() + operator!=(const tracker_allocator&, + const tracker_allocator&) throw() { return false; } bool @@ -331,7 +333,7 @@ namespace __gnu_test size_type max_size() const throw() - { return size_t(-1) / sizeof(Tp); } + { return size_type(-1) / sizeof(Tp); } void construct(pointer p, const Tp& val)