Commit e0fb1c5c by Dhruv Matani Committed by Paolo Carlini

list_sort_search.cc: Minor formatting fixes.

2004-04-12  Dhruv Matani  <dhruvbird@gmx.net>

	* testsuite/performance/20_util/allocator/list_sort_search.cc:
	Minor formatting fixes.
	* testsuite/performance/20_util/allocator/map_mt_find.cc:
	Likewise.

From-SVN: r80624
parent 9fabf579
2004-04-12 Dhruv Matani <dhruvbird@gmx.net>
* testsuite/performance/20_util/allocator/list_sort_search.cc:
Minor formatting fixes.
* testsuite/performance/20_util/allocator/map_mt_find.cc:
Likewise.
2004-04-12 Paolo Carlini <pcarlini@suse.de> 2004-04-12 Paolo Carlini <pcarlini@suse.de>
* config/locale/gnu/numeric_members.cc * config/locale/gnu/numeric_members.cc
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
// 2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com> // 2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com>
#include <list>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <typeinfo> #include <typeinfo>
#include <sstream> #include <sstream>
#include <ext/mt_allocator.h> #include <ext/mt_allocator.h>
...@@ -38,56 +42,52 @@ ...@@ -38,56 +42,52 @@
using namespace std; using namespace std;
using __gnu_cxx::malloc_allocator; using __gnu_cxx::malloc_allocator;
using __gnu_cxx::new_allocator;
using __gnu_cxx::__mt_alloc; using __gnu_cxx::__mt_alloc;
using __gnu_cxx::bitmap_allocator; using __gnu_cxx::bitmap_allocator;
using __gnu_cxx::__pool_alloc; using __gnu_cxx::__pool_alloc;
typedef int test_type; typedef int test_type;
using namespace __gnu_cxx;
#include <list>
#include <map>
#include <algorithm>
#include <cstdlib>
using namespace std;
template <typename Alloc> template <typename Alloc>
int Test_Allocator () int
{ Test_Allocator()
{
typedef list<int, Alloc> My_List; typedef list<int, Alloc> My_List;
My_List il1; My_List il1;
int const Iter = 150000; int const Iter = 150000;
int ctr = 3; int ctr = 3;
while (ctr--) while (ctr--)
{ {
for (int i = 0; i < Iter; ++i) for (int i = 0; i < Iter; ++i)
il1.push_back (rand()%500001); il1.push_back(rand()%500001);
//Search for random values that may or may not belong to the list. //Search for random values that may or may not belong to the list.
for (int i = 0; i < 50; ++i) for (int i = 0; i < 50; ++i)
std::find (il1.begin(), il1.end(), rand()%100001); std::find(il1.begin(), il1.end(), rand() % 100001);
il1.sort (); il1.sort();
//Search for random values that may or may not belong to the list. //Search for random values that may or may not belong to the list.
for (int i = 0; i < 50; ++i) for (int i = 0; i < 50; ++i)
{ {
typename My_List::iterator _liter = std::find (il1.begin(), il1.end(), rand()%100001); typename My_List::iterator _liter = std::find(il1.begin(),
il1.end(),
rand() % 100001);
if (_liter != il1.end()) if (_liter != il1.end())
il1.erase (_liter); il1.erase(_liter);
} }
il1.clear (); il1.clear();
} }
return Iter; return Iter;
} }
template <typename Alloc> template <typename Alloc>
void do_test () void
{ do_test()
{
using namespace __gnu_test; using namespace __gnu_test;
int status; int status;
Alloc obj; Alloc obj;
...@@ -100,14 +100,14 @@ void do_test () ...@@ -100,14 +100,14 @@ void do_test ()
stop_counters(time, resource); stop_counters(time, resource);
std::ostringstream comment; std::ostringstream comment;
comment << "iterations: " << test_iterations <<endl; comment << "iterations: " << test_iterations << '\t';
comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
0, 0, &status); 0, 0, &status);
report_header(__FILE__, comment.str()); report_header(__FILE__, comment.str());
report_performance(__FILE__, string(), time, resource); report_performance(__FILE__, string(), time, resource);
} }
int main () int main()
{ {
#ifdef TEST_S0 #ifdef TEST_S0
do_test<new_allocator<int> >(); do_test<new_allocator<int> >();
...@@ -125,5 +125,3 @@ int main () ...@@ -125,5 +125,3 @@ int main ()
do_test<__pool_alloc<int> >(); do_test<__pool_alloc<int> >();
#endif #endif
} }
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <pthread.h> #include <pthread.h>
#include <typeinfo> #include <typeinfo>
#include <sstream> #include <sstream>
#include <ext/mt_allocator.h> #include <ext/mt_allocator.h>
...@@ -44,17 +43,14 @@ ...@@ -44,17 +43,14 @@
using namespace std; using namespace std;
using __gnu_cxx::malloc_allocator; using __gnu_cxx::malloc_allocator;
using __gnu_cxx::new_allocator;
using __gnu_cxx::__mt_alloc; using __gnu_cxx::__mt_alloc;
using __gnu_cxx::bitmap_allocator; using __gnu_cxx::bitmap_allocator;
using __gnu_cxx::__pool_alloc; using __gnu_cxx::__pool_alloc;
typedef int test_type; typedef int test_type;
using namespace __gnu_cxx; bool less_int(int x1, int x2) { return x1<x2; }
using namespace std;
bool less_int (int x1, int x2) { return x1<x2; }
#if defined USE_FUNCTION_COMPARE #if defined USE_FUNCTION_COMPARE
#define COMPARE_T typeof(&less_int) #define COMPARE_T typeof(&less_int)
...@@ -65,25 +61,27 @@ bool less_int (int x1, int x2) { return x1<x2; } ...@@ -65,25 +61,27 @@ bool less_int (int x1, int x2) { return x1<x2; }
#endif #endif
template <typename Alloc> template <typename Alloc>
void *find_proc (void *_vptr) void*
{ find_proc(void *_vptr)
{
map<int, string, COMPARE_T, Alloc> *_mptr = map<int, string, COMPARE_T, Alloc> *_mptr =
reinterpret_cast<map<int, string, COMPARE_T, Alloc>*>(_vptr); reinterpret_cast<map<int, string, COMPARE_T, Alloc>*>(_vptr);
for (int i = 0; i < 700000; ++i) for (int i = 0; i < 700000; ++i)
{ {
int Finder = rand() % 2000000; int Finder = rand() % 2000000;
_mptr->find (Finder); _mptr->find(Finder);
} }
return _vptr; return _vptr;
} }
template <typename Alloc> template <typename Alloc>
int do_test () int
{ do_test()
{
COMPARE_T _comp = COMPARE_F; COMPARE_T _comp = COMPARE_F;
map<int, string, COMPARE_T, Alloc> imap (_comp); map<int, string, COMPARE_T, Alloc> imap(_comp);
int x = 2; int x = 2;
pthread_t thr[3]; pthread_t thr[3];
const int Iter = 1000000; const int Iter = 1000000;
...@@ -91,31 +89,32 @@ int do_test () ...@@ -91,31 +89,32 @@ int do_test ()
while (x--) while (x--)
{ {
for (int i = 0; i < 300000; ++i) for (int i = 0; i < 300000; ++i)
imap.insert (make_pair (rand()%1000000, "_test_data")); imap.insert(make_pair(rand()%1000000, "_test_data"));
for (int i = 0; i < 100000; ++i) for (int i = 0; i < 100000; ++i)
imap.insert (make_pair (rand()%2000000, "_test_data")); imap.insert(make_pair(rand()%2000000, "_test_data"));
pthread_create (&thr[0], NULL, find_proc<Alloc>, (void*)&imap); pthread_create(&thr[0], NULL, find_proc<Alloc>, (void*)&imap);
pthread_create (&thr[1], 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_create(&thr[2], NULL, find_proc<Alloc>, (void*)&imap);
pthread_join (thr[0], 0); pthread_join(thr[0], 0);
pthread_join (thr[1], 0); pthread_join(thr[1], 0);
pthread_join (thr[2], 0); pthread_join(thr[2], 0);
imap.clear (); imap.clear();
} }
return Iter; return Iter;
} }
template <typename Alloc> template <typename Alloc>
void exec_tests () void
{ exec_tests()
{
using namespace __gnu_test; using namespace __gnu_test;
int status; int status;
COMPARE_T _comp = COMPARE_F; COMPARE_T _comp = COMPARE_F;
map<int, string, COMPARE_T, Alloc> obj (_comp); map<int, string, COMPARE_T, Alloc> obj(_comp);
time_counter time; time_counter time;
resource_counter resource; resource_counter resource;
...@@ -125,13 +124,12 @@ void exec_tests () ...@@ -125,13 +124,12 @@ void exec_tests ()
stop_counters(time, resource); stop_counters(time, resource);
std::ostringstream comment; std::ostringstream comment;
comment << "iterations: " << test_iterations <<endl; comment << "iterations: " << test_iterations << '\t';
comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
0, 0, &status); 0, 0, &status);
report_header(__FILE__, comment.str()); report_header(__FILE__, comment.str());
report_performance(__FILE__, string(), time, resource); report_performance(__FILE__, string(), time, resource);
} }
int main() int main()
{ {
......
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