+2006-10-03 Benjamin Kosnik <bkoz@redhat.com>
+
+ * 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 <bkoz@redhat.com>
* testsuite/util/native_type/priority_queue/native_pq_tag.hpp: Remove.
int main()
{
- typedef std::deque<int, tracker_alloc<int> > Container;
+ typedef std::deque<int, tracker_allocator<int> > 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;
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;
{
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;
}
{
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;
}
{
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;
}
#include <testsuite_hooks.h>
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;
{
// setup
typedef copy_tracker T;
- typedef std::deque<T, tracker_alloc<T> > X;
+ typedef std::deque<T, tracker_allocator<T> > X;
T::reset();
copy_constructor::throw_on(3);
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
// test
try
}
// assert postconditions
- VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal());
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
// teardown
}
{
// setup
typedef copy_tracker T;
- typedef std::deque<T, tracker_alloc<T> > X;
+ typedef std::deque<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
T::reset();
}
// assert postconditions
- VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal());
+ VERIFY(tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count());
// teardown
}
int main()
{
- typedef std::list<int, tracker_alloc<int> > Container;
+ typedef std::list<int, tracker_allocator<int> > 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;
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;
{
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;
}
{
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);
{
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);
int main()
{
- typedef std::set<int, std::less<int>, tracker_alloc<int> > Container;
+ typedef std::set<int, std::less<int>, tracker_allocator<int> > 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;
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;
{
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;
}
{
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;
}
{
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;
}
#include <testsuite_hooks.h>
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;
{
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(3);
const X::size_type old_size = a.size();
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
{
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
const X::size_type old_size __attribute__((unused)) = a.size();
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()
int main()
{
- typedef std::vector<int, tracker_alloc<int> > Container;
+ typedef std::vector<int, tracker_allocator<int> > 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;
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;
{
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;
}
{
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;
}
{
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;
}
#include <testsuite_hooks.h>
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;
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
copy_tracker::reset();
copy_constructor::throw_on(3);
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
// run test
try
}
// assert postconditions
- VERIFY( allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal() );
+ VERIFY( tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count() );
// teardown
}
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
copy_tracker::reset();
}
// 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=()
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > 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());
// 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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > 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());
// 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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X r(1);
X a(r.capacity() + 7);
// 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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X r(1);
X a(r.capacity() + 7);
}
// 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()
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
X a(7);
X::size_type old_size = a.size();
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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
X a(7);
a.reserve(11);
const T t;
copy_tracker::reset();
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
// assert preconditions
VERIFY(old_size < new_size);
// 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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
X::size_type old_capacity = a.capacity();
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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
X::size_type old_size = a.size();
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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
X a(7);
X::size_type old_size = a.size();
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()
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
X a(7);
X b(3);
copy_tracker::reset();
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
// assert preconditions
VERIFY(b.size() < a.capacity());
// 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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > 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());
// 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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
X b(a.capacity() + 7);
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
// setup
bool test __attribute__((unused)) = true;
typedef copy_tracker T;
- typedef std::vector<T, tracker_alloc<T> > X;
+ typedef std::vector<T, tracker_allocator<T> > X;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
X a(7);
X b(a.capacity() + 7);
}
// 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();
}
namespace std
{
using __gnu_test::pod_char;
- typedef __gnu_test::tracker_alloc<char> alloc_type;
+ typedef __gnu_test::tracker_allocator<char> alloc_type;
template class basic_stringbuf<char, char_traits<char>, alloc_type>;
} // test
int main()
{
typedef __gnu_cxx::hash_set<int, __gnu_cxx::hash<int>, std::equal_to<int>,
- tracker_alloc<int> >
+ tracker_allocator<int> >
Container;
const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
int buckets;
- allocation_tracker::resetCounts();
+ tracker_allocator_counter::reset();
{
Container c;
buckets = c.bucket_count();
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]);
}
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);
}
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);
int main()
{
- typedef __gnu_cxx::slist<int, tracker_alloc<int> > Container;
+ typedef __gnu_cxx::slist<int, tracker_allocator<int> > 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;
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;
{
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;
}
{
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);
{
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);
*/
#include <ext/typelist.h>
+#include <testsuite_allocator.h>
#include <performance/io/xml_formatter.hpp>
#include <io/verified_cmd_line_input.hpp>
#include <rng/twister_rand_gen.hpp>
#include <common_type/assoc/common_type.hpp>
#include <performance/assoc/mem_usage/erase_test.hpp>
-#include <performance/mem/mem_track_allocator.hpp>
#include <iostream>
#include <vector>
#include <functional>
vec_t::const_iterator b = a_v.begin();
erase_test<vec_t::const_iterator> tst(b, vn, vs, vm);
- typedef mem_track_allocator<char> alloc_t;
+ typedef __gnu_test::tracker_allocator<char> alloc_t;
{
typedef hash_common_types<int, pb_ds::null_mapped_type, int_hash, std::equal_to<int>, alloc_t>::performance_tl tl_t;
* 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/assoc/native_hash_multimap.hpp>
#include <common_type/assoc/common_type.hpp>
#include <performance/assoc/mem_usage/multimap_insert_test.hpp>
#include <performance/assoc/multimap_common_type.hpp>
-#include <performance/mem/mem_track_allocator.hpp>
#include <hash_fn/string_hash_fn.hpp>
-#include <iostream>
-#include <vector>
void
usage();
init_vec_t a_v_init(prm);
distinct_text_populate(f_name, a_v_init);
- typedef mem_track_allocator<char> alloc_t;
+ 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;
* 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/priority_queue/native_priority_queue.hpp>
-#include <performance/mem/mem_track_allocator.hpp>
-#include <iostream>
-#include <vector>
void
usage();
try
{
xml_test_performance_formatter fmt("Size", "Memory (bytes)");
+ typedef __gnu_test::tracker_allocator<char> callocator_type;
+ typedef __gnu_test::tracker_allocator<char> sallocator_type;
+ typedef std::basic_string<char, std::char_traits<char>, callocator_type> string_t;
- typedef std::basic_string<char, std::char_traits<char>, mem_track_allocator<char> > string_t;
-
- typedef std::vector<std::pair< string_t, char> > vec_t;
+ typedef std::vector<std::pair<string_t, char> > vec_t;
vec_t a_v(vm);
text_populate(f_name, a_v);
vec_t::const_iterator b = a_v.begin();
test_t tst(b, vn, vs, vm);
{
- typedef pq_common_types<string_t, std::less<string_t>, mem_track_allocator<char> >::performance_tl pq_tl_t;
+ typedef pq_common_types<string_t, std::less<string_t>, callocator_type>::performance_tl pq_tl_t;
pq_tl_t tl;
__gnu_cxx::typelist::apply(tst, tl);
}
{
- typedef native_priority_queue<string_t, true, std::less<string_t>, mem_track_allocator<string_t> > native_pq_t;
+ typedef native_priority_queue<string_t, true, std::less<string_t>, sallocator_type> native_pq_t;
tst(native_pq_t());
}
{
- typedef native_priority_queue<string_t, false, std::less<string_t>, mem_track_allocator<string_t> > native_pq_t;
+ typedef native_priority_queue<string_t, false, std::less<string_t>, sallocator_type> native_pq_t;
tst(native_pq_t());
}
}
#ifndef PB_DS_ERASE_TEST_HPP
#define PB_DS_ERASE_TEST_HPP
+#include <iterator>
+#include <testsuite_allocator.h>
#include <ext/pb_ds/detail/type_utils.hpp>
-#include <performance/mem/mem_track_allocator.hpp>
#include <performance/io/xml_formatter.hpp>
#include <common_type/assoc/string_form.hpp>
-#include <iterator>
namespace pb_ds
{
It ins_it_e = m_ins_b;
std::advance(ins_it_e, ins_size);
- mem_track_allocator<char> alloc;
- const size_t init_mem = alloc.get_total();
+ __gnu_test::tracker_allocator<char> 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<double>(delta_mem));
#ifndef PB_DS_MULTIMAP_INSERT_TEST_HPP
#define PB_DS_MULTIMAP_INSERT_TEST_HPP
+#include <iterator>
#include <ext/pb_ds/detail/type_utils.hpp>
-#include <performance/mem/mem_track_allocator.hpp>
+#include <testsuite_allocator.h>
#include <performance/io/xml_formatter.hpp>
#include <common_type/assoc/string_form.hpp>
-#include <iterator>
namespace pb_ds
{
multimap_insert_test<It, Native>::
insert(Cntnr, It ins_it_b, It ins_it_e, pb_ds::detail::true_type)
{
- mem_track_allocator<char> alloc;
- const size_t init_mem = alloc.get_total();
+ __gnu_test::tracker_allocator<char> 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);
}
multimap_insert_test<It, Native>::
insert(Cntnr, It ins_it_b, It ins_it_e, pb_ds::detail::false_type)
{
- mem_track_allocator<char> alloc;
- const size_t init_mem = alloc.get_total();
+ __gnu_test::tracker_allocator<char> 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);
}
+++ /dev/null
-// -*- 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 <performance/mem/mem_track_allocator_base.hpp>
-
-namespace pb_ds
-{
-
- namespace test
- {
-
-#define PB_DS_CLASS_T_DEC \
- template<typename T>
-
-#define PB_DS_CLASS_C_DEC \
- mem_track_allocator< \
- T>
-
- template<typename T>
- 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<typename U>
- struct rebind
- {
- typedef mem_track_allocator<U> other;
- };
-
- mem_track_allocator() throw();
-
- mem_track_allocator(const PB_DS_CLASS_C_DEC& ) throw();
-
- template <class U>
- mem_track_allocator(const mem_track_allocator<U>& ) throw();
-
- ~mem_track_allocator() throw();
-
- size_type
- max_size() const throw();
-
- pointer
- allocate(size_type num, std::allocator<void>::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<typename U>
- PB_DS_CLASS_C_DEC::
- mem_track_allocator(const mem_track_allocator<U>& ) 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<T>().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<void>::const_pointer hint/*= 0*/)
- {
- T* const a_t = std::allocator<T>().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<T>().construct(p, r_val));
- }
-
- PB_DS_CLASS_T_DEC
- void
- PB_DS_CLASS_C_DEC::
- destroy(pointer p)
- {
- std::allocator<T>().destroy(p);
- }
-
- PB_DS_CLASS_T_DEC
- void
- PB_DS_CLASS_C_DEC::
- deallocate(pointer p, size_type num)
- {
- std::allocator<T>().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
+++ /dev/null
-// -*- 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 <cassert>
-
-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
#ifndef PB_DS_POP_TEST_HPP
#define PB_DS_POP_TEST_HPP
+#include <iterator>
+#include <testsuite_allocator.h>
#include <ext/pb_ds/detail/type_utils.hpp>
-#include <performance/mem/mem_track_allocator.hpp>
#include <performance/io/xml_formatter.hpp>
#include <common_type/priority_queue/string_form.hpp>
-#include <iterator>
namespace pb_ds
{
It ins_it_e = m_ins_b;
std::advance(ins_it_e, ins_size);
- mem_track_allocator<char> alloc;
+ __gnu_test::tracker_allocator<char> 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);
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<double>(delta_mem));
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
#define _GLIBCXX_TESTSUITE_ALLOCATOR_H
#include <cstddef>
-#include <limits>
#include <tr1/unordered_map>
#include <cassert>
namespace __gnu_test
{
- class allocation_tracker
+ class tracker_allocator_counter
{
public:
typedef std::size_t size_type;
static void*
allocate(size_type blocksize)
{
- allocationTotal_ += blocksize;
+ allocationCount_ += blocksize;
return ::operator new(blocksize);
}
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 T>
- class tracker_alloc
+ class tracker_allocator
{
+ private:
+ typedef tracker_allocator_counter counter_type;
+
public:
typedef T value_type;
typedef T* pointer;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
- template<class U> struct rebind { typedef tracker_alloc<U> other; };
+ template<class U> struct rebind { typedef tracker_allocator<U> other; };
pointer
address(reference value) const
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<class U>
- tracker_alloc(const tracker_alloc<U>&) throw()
+ tracker_allocator(const tracker_allocator<U>&) throw()
{ }
- ~tracker_alloc() throw()
+ ~tracker_allocator() throw()
{ }
size_type
max_size() const throw()
- { return std::numeric_limits<std::size_t>::max() / sizeof(T); }
+ { return size_type(-1) / sizeof(T); }
pointer
allocate(size_type n, const void* = 0)
- {
- return static_cast<pointer>(allocation_tracker::allocate(n * sizeof(T)));
- }
+ { return static_cast<pointer>(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<class T1, class T2>
bool
- operator==(const tracker_alloc<T1>&, const tracker_alloc<T2>&) throw()
+ operator==(const tracker_allocator<T1>&,
+ const tracker_allocator<T2>&) throw()
{ return true; }
template<class T1, class T2>
bool
- operator!=(const tracker_alloc<T1>&, const tracker_alloc<T2>&) throw()
+ operator!=(const tracker_allocator<T1>&,
+ const tracker_allocator<T2>&) throw()
{ return false; }
bool
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)