|
Boost : |
Subject: Re: [boost] Proposal: Monotonic Containers: Performance test
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-10 23:27:26
You will note that I made a mistake, and used the same timer for both. This
gave an incorrect result, as the std:: timer included the time for the first
test. Even so, it was 9x faster rather than 10x faster.
Another test, this time with more list insertions:
void test_speed()
{
typedef monotonic::map<int, monotonic::list<int> > map_with_list;
monotonic::inline_storage<1000000> storage;
map_with_list m(storage);
size_t count = 10000;
boost::timer timer;
for (size_t i = 0; i < count; ++i)
{
int random = rand() % 100;
map_with_list::iterator iter = m.find(random);
if (iter == m.end())
m.insert(make_pair(random, monotonic::list<int>(storage)));
else
iter->second.push_back(i);
}
double elapsed = timer.elapsed();
cout << "monotonic: " << elapsed << endl;
// do the same thing, with std::containers
{
typedef std::map<int, std::list<int> > map_with_list;
map_with_list m;
boost::timer timer;
for (size_t i = 0; i < count; ++i)
{
int random = rand() % 100;
map_with_list::iterator iter = m.find(random);
if (iter == m.end())
m[random] = std::list<int>();
else
iter->second.push_back(i);
}
double elapsed = timer.elapsed();
cout << "std: " << elapsed << endl;
}
}
monotonic: 0.001
std: 0.017
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk