Commit 009368db by Dhruv Matani Committed by Loren J. Rittle

ballocator_doc.txt: New file.

2004-03-11  Dhruv Matani  <dhruvbird@HotPOP.com>

	* docs/html/ext/ballocator_doc.txt: New file.
	* include/Makefile.am (ext_headers): Add
	${ext_srcdir}/bitmap_allocator.h .
	* include/Makefile.in: Regenerate (by hand, since I didn't have
	automake de jure on hand).
	* include/ext/bitmap_allocator.h: New file.
	* testsuite/performance/20_util/allocator/list_sort_search.cc: New test.
	* testsuite/performance/20_util/allocator/map_mt_find.cc: Likewise.
	* testsuite/performance/20_util/allocator/producer_consumer.cc: Add
	test for the bitmap_allocator<>.
	* testsuite/performance/20_util/allocator/insert.cc: Likewise.
	* testsuite/performance/20_util/allocator/insert_insert.cc: Likewise.
	* testsuite/performance/20_util/allocator/map_thread.cc: Likewise.

From-SVN: r79366
parent a8dad789
2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com>
* include/Makefile.am (ext_headers): Add
${ext_srcdir}/bitmap_allocator.h .
* include/Makefile.in: Regenerate.
* docs/html/ext/ballocator_doc.txt: New file.
* include/ext/bitmap_allocator.h: New file.
* testsuite/performance/20_util/allocator/list_sort_search.cc: New test.
* testsuite/performance/20_util/allocator/map_mt_find.cc: Likewise.
* testsuite/performance/20_util/allocator/producer_consumer.cc: Add
test for the bitmap_allocator<>.
* testsuite/performance/20_util/allocator/insert.cc: Likewise.
* testsuite/performance/20_util/allocator/insert_insert.cc: Likewise.
* testsuite/performance/20_util/allocator/map_thread.cc: Likewise.
2004-03-11 Paolo Carlini <pcarlini@suse.de>
* include/std/std_complex.h (pow(const complex&, const _Tp&),
......
......@@ -202,6 +202,7 @@ ext_srcdir = ${glibcxx_srcdir}/include/ext
ext_builddir = ./ext
ext_headers = \
${ext_srcdir}/algorithm \
${ext_srcdir}/bitmap_allocator.h \
${ext_srcdir}/debug_allocator.h \
${ext_srcdir}/demangle.h \
${ext_srcdir}/enc_filebuf.h \
......
......@@ -411,6 +411,7 @@ ext_srcdir = ${glibcxx_srcdir}/include/ext
ext_builddir = ./ext
ext_headers = \
${ext_srcdir}/algorithm \
${ext_srcdir}/bitmap_allocator.h \
${ext_srcdir}/debug_allocator.h \
${ext_srcdir}/demangle.h \
${ext_srcdir}/enc_filebuf.h \
......
......@@ -43,6 +43,7 @@
#include <ext/mt_allocator.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/bitmap_allocator.h>
#include <cxxabi.h>
#include <testsuite_performance.h>
......@@ -146,6 +147,7 @@ int main(void)
typedef __gnu_cxx::malloc_allocator<test_type> m_alloc_type;
typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
typedef __gnu_cxx::bitmap_allocator<test_type> bit_alloc_type;
#ifdef TEST_B0
test_container(vector<test_type, m_alloc_type>());
......@@ -156,47 +158,62 @@ int main(void)
#ifdef TEST_B2
test_container(vector<test_type, so_alloc_type>());
#endif
#ifdef TEST_B3
test_container(list<test_type, m_alloc_type>());
test_container(vector<test_type, bit_alloc_type>());
#endif
#ifdef TEST_B4
test_container(list<test_type, n_alloc_type>());
test_container(list<test_type, m_alloc_type>());
#endif
#ifdef TEST_B5
test_container(list<test_type, n_alloc_type>());
#endif
#ifdef TEST_B6
test_container(list<test_type, so_alloc_type>());
#endif
#ifdef TEST_B7
test_container(list<test_type, bit_alloc_type>());
#endif
#ifdef TEST_B6
#ifdef TEST_B8
test_container(deque<test_type, m_alloc_type>());
#endif
#ifdef TEST_B7
#ifdef TEST_B9
test_container(deque<test_type, n_alloc_type>());
#endif
#ifdef TEST_B8
#ifdef TEST_B10
test_container(deque<test_type, so_alloc_type>());
#endif
#ifdef TEST_B11
test_container(deque<test_type, bit_alloc_type>());
#endif
typedef less<test_type> compare_type;
#ifdef TEST_B9
#ifdef TEST_B12
test_container(map<test_type, test_type, compare_type, m_alloc_type>());
#endif
#ifdef TEST_B10
#ifdef TEST_B13
test_container(map<test_type, test_type, compare_type, n_alloc_type>());
#endif
#ifdef TEST_B11
#ifdef TEST_B14
test_container(map<test_type, test_type, compare_type, so_alloc_type>());
#endif
#ifdef TEST_B15
test_container(map<test_type, test_type, compare_type, bit_alloc_type>());
#endif
#ifdef TEST_B12
#ifdef TEST_B16
test_container(set<test_type, compare_type, m_alloc_type>());
#endif
#ifdef TEST_B13
#ifdef TEST_B17
test_container(set<test_type, compare_type, n_alloc_type>());
#endif
#ifdef TEST_B14
#ifdef TEST_B18
test_container(set<test_type, compare_type, so_alloc_type>());
#endif
#ifdef TEST_B19
test_container(set<test_type, compare_type, bit_alloc_type>());
#endif
#ifdef TEST_T0
test_container(vector<test_type, m_alloc_type>(), true);
......@@ -207,47 +224,62 @@ int main(void)
#ifdef TEST_T2
test_container(vector<test_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T3
test_container(list<test_type, m_alloc_type>(), true);
test_container(vector<test_type, bit_alloc_type>(), true);
#endif
#ifdef TEST_T4
test_container(list<test_type, n_alloc_type>(), true);
test_container(list<test_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T5
test_container(list<test_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T6
test_container(list<test_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T7
test_container(list<test_type, bit_alloc_type>(), true);
#endif
#ifdef TEST_T6
#ifdef TEST_T8
test_container(deque<test_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T7
#ifdef TEST_T9
test_container(deque<test_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T8
#ifdef TEST_T10
test_container(deque<test_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T11
test_container(deque<test_type, bit_alloc_type>(), true);
#endif
typedef less<test_type> compare_type;
#ifdef TEST_T9
#ifdef TEST_T12
test_container(map<test_type, test_type, compare_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T10
#ifdef TEST_T13
test_container(map<test_type, test_type, compare_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T11
#ifdef TEST_T14
test_container(map<test_type, test_type, compare_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T15
test_container(map<test_type, test_type, compare_type, bit_alloc_type>(), true);
#endif
#ifdef TEST_T12
#ifdef TEST_T16
test_container(set<test_type, compare_type, m_alloc_type>(), true);
#endif
#ifdef TEST_T13
#ifdef TEST_T17
test_container(set<test_type, compare_type, n_alloc_type>(), true);
#endif
#ifdef TEST_T14
#ifdef TEST_T18
test_container(set<test_type, compare_type, so_alloc_type>(), true);
#endif
#ifdef TEST_T19
test_container(set<test_type, compare_type, bit_alloc_type>(), true);
#endif
return 0;
}
......@@ -43,6 +43,7 @@
#include <ext/mt_allocator.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/bitmap_allocator.h>
#include <cxxabi.h>
#include <testsuite_performance.h>
......@@ -117,6 +118,7 @@ int main(void)
typedef __gnu_cxx::malloc_allocator<test_type> m_alloc_type;
typedef __gnu_cxx::new_allocator<test_type> n_alloc_type;
typedef __gnu_cxx::__mt_alloc<test_type> so_alloc_type;
typedef __gnu_cxx::bitmap_allocator<test_type> bit_alloc_type;
#ifdef TEST_S0
test_container(vector<test_type, m_alloc_type>());
......@@ -127,37 +129,52 @@ int main(void)
#ifdef TEST_S2
test_container(vector<test_type, so_alloc_type>());
#endif
#ifdef TEST_S3
test_container(list<test_type, m_alloc_type>());
test_container(vector<test_type, bit_alloc_type>());
#endif
#ifdef TEST_S4
test_container(list<test_type, n_alloc_type>());
test_container(list<test_type, m_alloc_type>());
#endif
#ifdef TEST_S5
test_container(list<test_type, n_alloc_type>());
#endif
#ifdef TEST_S6
test_container(list<test_type, so_alloc_type>());
#endif
#ifdef TEST_S7
test_container(list<test_type, bit_alloc_type>());
#endif
#ifdef TEST_S6
#ifdef TEST_S8
test_container(deque<test_type, m_alloc_type>());
#endif
#ifdef TEST_S7
#ifdef TEST_S9
test_container(deque<test_type, n_alloc_type>());
#endif
#ifdef TEST_S8
#ifdef TEST_S10
test_container(deque<test_type, so_alloc_type>());
#endif
#ifdef TEST_S11
test_container(deque<test_type, bit_alloc_type>());
#endif
typedef less<test_type> compare_type;
#ifdef TEST_S9
#ifdef TEST_S12
test_container(map<test_type, test_type, compare_type, m_alloc_type>());
#endif
#ifdef TEST_S10
#ifdef TEST_S13
test_container(map<test_type, test_type, compare_type, n_alloc_type>());
#endif
#ifdef TEST_S11
#ifdef TEST_S14
test_container(map<test_type, test_type, compare_type, so_alloc_type>());
#endif
#ifdef TEST_S15
test_container(map<test_type, test_type, compare_type, bit_alloc_type>());
#endif
#ifdef TEST_S12
test_container(set<test_type, compare_type, m_alloc_type>());
......@@ -168,6 +185,9 @@ int main(void)
#ifdef TEST_S14
test_container(set<test_type, compare_type, so_alloc_type>());
#endif
#ifdef TEST_S14
test_container(set<test_type, compare_type, bit_alloc_type>());
#endif
return 0;
}
// Copyright (C) 2004 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.
// 2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com>
#include <typeinfo>
#include <sstream>
#include <ext/mt_allocator.h>
#include <ext/malloc_allocator.h>
#include <cxxabi.h>
#include <testsuite_performance.h>
#include <ext/bitmap_allocator.h>
using namespace std;
using __gnu_cxx::malloc_allocator;
using __gnu_cxx::__mt_alloc;
using __gnu_cxx::bitmap_allocator;
typedef int test_type;
using namespace __gnu_cxx;
#include <list>
#include <map>
#include <algorithm>
#include <cstdlib>
using namespace std;
template <typename Alloc>
int Test_Allocator ()
{
typedef list<int, Alloc> My_List;
My_List il1;
int const Iter = 150000;
int ctr = 3;
while (ctr--)
{
for (int i = 0; i < Iter; ++i)
il1.push_back (rand()%500001);
//Search for random values that may or may not belong to the list.
for (int i = 0; i < 50; ++i)
std::find (il1.begin(), il1.end(), rand()%100001);
il1.sort ();
//Search for random values that may or may not belong to the list.
for (int i = 0; i < 50; ++i)
{
typename My_List::iterator _liter = std::find (il1.begin(), il1.end(), rand()%100001);
if (_liter != il1.end())
il1.erase (_liter);
}
il1.clear ();
}
return Iter;
}
template <typename Alloc>
void do_test ()
{
using namespace __gnu_test;
int status;
Alloc obj;
time_counter time;
resource_counter resource;
clear_counters(time, resource);
start_counters(time, resource);
int test_iterations = Test_Allocator<Alloc>();
stop_counters(time, resource);
std::ostringstream comment;
comment << "iterations: " << test_iterations <<endl;
comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
0, 0, &status);
report_header(__FILE__, comment.str());
report_performance(__FILE__, string(), time, resource);
}
int main ()
{
#ifdef TEST_S0
do_test<new_allocator<int> >();
#endif
#ifdef TEST_S1
do_test<malloc_allocator<int> >();
#endif
#ifdef TEST_S2
do_test<bitmap_allocator<int> >();
#endif
#ifdef TEST_S3
do_test<__mt_alloc<int> >();
#endif
}
// Copyright (C) 2004 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.
// 2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com>
#include <new>
#include <map>
#include <cstdlib>
#include <string>
#include <pthread.h>
#include <typeinfo>
#include <sstream>
#include <ext/mt_allocator.h>
#include <ext/malloc_allocator.h>
#include <cxxabi.h>
#include <testsuite_performance.h>
#include <ext/bitmap_allocator.h>
using namespace std;
using __gnu_cxx::malloc_allocator;
using __gnu_cxx::__mt_alloc;
using __gnu_cxx::bitmap_allocator;
typedef int test_type;
using namespace __gnu_cxx;
using namespace std;
bool less_int (int x1, int x2) { return x1<x2; }
#if defined USE_FUNCTION_COMPARE
#define COMPARE_T typeof(&less_int)
#define COMPARE_F &less_int
#else
#define COMPARE_T std::less<int>
#define COMPARE_F std::less<int>()
#endif
template <typename Alloc>
void *find_proc (void *_vptr)
{
map<int, string, COMPARE_T, Alloc> *_mptr =
reinterpret_cast<map<int, string, COMPARE_T, Alloc>*>(_vptr);
for (int i = 0; i < 700000; ++i)
{
int Finder = rand() % 2000000;
_mptr->find (Finder);
}
return _vptr;
}
template <typename Alloc>
int do_test ()
{
COMPARE_T _comp = COMPARE_F;
map<int, string, COMPARE_T, Alloc> imap (_comp);
int x = 2;
pthread_t thr[3];
const int Iter = 1000000;
while (x--)
{
for (int i = 0; i < 300000; ++i)
imap.insert (make_pair (rand()%1000000, "_test_data"));
for (int i = 0; i < 100000; ++i)
imap.insert (make_pair (rand()%2000000, "_test_data"));
pthread_create (&thr[0], NULL, find_proc<Alloc>, (void*)&imap);
pthread_create (&thr[1], NULL, find_proc<Alloc>, (void*)&imap);
pthread_create (&thr[2], NULL, find_proc<Alloc>, (void*)&imap);
pthread_join (thr[0], 0);
pthread_join (thr[1], 0);
pthread_join (thr[2], 0);
imap.clear ();
}
return Iter;
}
template <typename Alloc>
void exec_tests ()
{
using namespace __gnu_test;
int status;
COMPARE_T _comp = COMPARE_F;
map<int, string, COMPARE_T, Alloc> obj (_comp);
time_counter time;
resource_counter resource;
clear_counters(time, resource);
start_counters(time, resource);
int test_iterations = do_test<Alloc>();
stop_counters(time, resource);
std::ostringstream comment;
comment << "iterations: " << test_iterations <<endl;
comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
0, 0, &status);
report_header(__FILE__, comment.str());
report_performance(__FILE__, string(), time, resource);
}
int main()
{
#ifdef TEST_T0
exec_tests<new_allocator<int> >();
#endif
#ifdef TEST_T1
exec_tests<malloc_allocator<int> >();
#endif
#ifdef TEST_T2
exec_tests<bitmap_allocator<int> >();
#endif
#ifdef TEST_T3
exec_tests<__mt_alloc<int> >();
#endif
}
......@@ -40,6 +40,7 @@
#include <ext/mt_allocator.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/bitmap_allocator.h>
#include <cxxabi.h>
#include <testsuite_performance.h>
......@@ -47,6 +48,7 @@ using namespace std;
using __gnu_cxx::__mt_alloc;
using __gnu_cxx::new_allocator;
using __gnu_cxx::malloc_allocator;
using __gnu_cxx::bitmap_allocator;
// The number of iterations to be performed.
int iterations = 10000;
......@@ -120,6 +122,10 @@ int main(void)
test_container(map<int, int, less<const int>,
__mt_alloc< pair<const int, int> > >());
#endif
#ifdef TEST_T5
test_container(map<int, int, less<const int>, bitmap_allocator<int> >());
#endif
return 0;
}
......@@ -41,6 +41,7 @@
#include <ext/mt_allocator.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/bitmap_allocator.h>
#include <cxxabi.h>
#include <testsuite_performance.h>
......@@ -49,6 +50,7 @@ using namespace std;
using __gnu_cxx::__mt_alloc;
using __gnu_cxx::new_allocator;
using __gnu_cxx::malloc_allocator;
using __gnu_cxx::bitmap_allocator;
using abi::__cxa_demangle;
typedef int test_type;
......@@ -56,6 +58,7 @@ typedef less<test_type> compare_type;
typedef malloc_allocator<test_type> malloc_alloc_type;
typedef new_allocator<test_type> new_alloc_type;
typedef __mt_alloc<test_type> so_alloc_type;
typedef bitmap_allocator<test_type> bit_alloc_type;
// The number of iterations to be performed.
int iterations = 10000;
......@@ -292,6 +295,10 @@ int main(void)
#ifdef TEST_T3
test_container(vector<test_type, so_alloc_type>());
#endif
#ifdef TEST_T4
test_container(vector<test_type, bit_alloc_type>());
#endif
#ifdef TEST_T5
test_container(list<test_type, malloc_alloc_type>());
......@@ -302,6 +309,10 @@ int main(void)
#ifdef TEST_T7
test_container(list<test_type, so_alloc_type>());
#endif
#ifdef TEST_T8
test_container(list<test_type, bit_alloc_type>());
#endif
#ifdef TEST_T9
test_container(map<test_type, test_type, compare_type, malloc_alloc_type>());
......@@ -312,6 +323,10 @@ int main(void)
#ifdef TEST_T11
test_container(map<test_type, test_type, compare_type, so_alloc_type>());
#endif
#ifdef TEST_T12
test_container(map<test_type, test_type, compare_type, bit_alloc_type>());
#endif
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment