This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Please could you run this test on your machine?
- From: Dhruv Matani <dhruvbird at gmx dot net>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Cc: Stefan Olsson <stefan at xapa dot se>
- Date: 20 Feb 2004 21:14:44 +0530
- Subject: Please could you run this test on your machine?
- Organization:
I would like to know the result of this test on Machines with multiple
CPU's as well as a single CPU. I would expect this test to do well in a
single CPU environment, but test results may not agree with me. This
test actually emulates a real world app.
You can leave out testing bitmap_allocator for now.
I am interested in knowing the cache performance of the default alloctor
v/s the __mt_alloc mainly.
On my single CPU Duron 1GHz, 640MB DDR SD RAM, the results are like
this:
//__mt_alloc.
[dhruv@localhost test]$ compile map_test.cpp v4 -lpthread -O3
The Compiler command passed is: g++34 -Wall -lpthread -O3 -o map_test
map_test.cpp
[dhruv@localhost test]$ time ./map_test
Size of Map is: 20
Time taken to Insert: 4.82 Seconds.
Time taken to Find: 0 Seconds.
Time taken to Clear: 1.07 Seconds.
Time taken to Insert: 6.12 Seconds.
Time taken to Find: 0 Seconds.
Time taken to Clear: 1.16 Seconds.
real 1m23.004s
user 1m22.730s
sys 0m0.110s
//std::allocator, which AFAICS is currently new_allocator.
[dhruv@localhost test]$ compile map_test.cpp v4 -lpthread -O3
The Compiler command passed is: g++34 -Wall -lpthread -O3 -o map_test
map_test.cpp
[dhruv@localhost test]$ time ./map_test
Size of Map is: 20
Time taken to Insert: 4.61 Seconds.
Time taken to Find: 0 Seconds.
Time taken to Clear: 0.62 Seconds.
Time taken to Insert: 5.91 Seconds.
Time taken to Find: 0 Seconds.
Time taken to Clear: 0.62 Seconds.
real 1m19.806s
user 1m19.340s
sys 0m0.220s
[dhruv@localhost test]$
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
Proud to be a Vegetarian.
http://www.vegetarianstarterkit.com/
http://www.vegkids.com/vegkids/index.html
#include <new>
#include <iostream>
#include <nstl/timer.hpp>
#include <map>
#include <ext/bitmap_allocator.h>
#include <ext/mt_allocator.h>
#include <cstdlib>
#include <string>
#include <pthread.h>
using namespace __gnu_cxx;
using namespace std;
bool less_int (int x1, int x2) { return x1<x2; }
//#define USE_FUNCTION_COMPARE
//#define USE_BITMAP_ALLOCATOR
//#define USE_MT_ALLOCATOR
#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
#if defined USE_BITMAP_ALLOCATOR
#define MAP_ALLOC bitmap_allocator<int>
#else
#if defined USE_MT_ALLOCATOR
#define MAP_ALLOC __mt_alloc<int>
#else
#define MAP_ALLOC std::allocator<int>
#endif
#endif
void *find_proc (void *_vptr)
{
map<int, string, COMPARE_T, MAP_ALLOC> *_mptr =
reinterpret_cast<map<int, string, COMPARE_T, MAP_ALLOC>*>(_vptr);
for (int i = 0; i < 3000000; ++i)
_mptr->find (rand() % 2000000);
return _vptr;
}
int main()
{
COMPARE_T _comp = COMPARE_F;
map<int, string, COMPARE_T, MAP_ALLOC> imap (_comp);
nstd::timer t;
pthread_t thr[3];
cout<<"Size of Map is: "<<sizeof(imap)<<endl;
int x = 2;
while (x--)
{
t.start();
for (int i = 0; i < 1000000; ++i)
imap.insert (make_pair (rand()%1000000, "_test_data"));
for (int i = 0; i < 100000; ++i)
imap.insert (make_pair (rand()%2000000, "_test_data"));
t.stop();
cout<<"Time taken to Insert: "<<t()<<" Seconds."<<endl;
t.start();
pthread_create (&thr[0], NULL, find_proc, (void*)&imap);
pthread_create (&thr[1], NULL, find_proc, (void*)&imap);
pthread_create (&thr[2], NULL, find_proc, (void*)&imap);
pthread_join (thr[0], 0);
pthread_join (thr[1], 0);
pthread_join (thr[2], 0);
t.stop();
cout<<"Time taken to Find: "<<t()<<" Seconds."<<endl;
t.start();
imap.clear ();
t.stop();
cout<<"Time taken to Clear: "<<t()<<" Seconds."<<endl;
}
// int temp;
// cin>>temp;
}