I find it a little bit weird that you should get a 100% speed improvement.
Traversing the xorpointer should be slower in my view. How did you test it
ans what did you test? (e.g. did you test splice?)
I had the same sentiments, the test is pretty trivial and indeed didn't try
splice neither I implemented splice the feature that were introduced in
C++2003 (could be wrong, all the same these methods are not implemented
are commented out as "TODO" section in the header.
Here's a snip what was tested and how, mostly insertion time and iteration
rate.
// snip snip some includes removed
// ---------------------------------------------------------
// profile
// ---------------------------------------------------------
template <typename container>
void profile(core::timer* xtimer, const char* name, const int size)
{
typedef typename container::iterator iterator;
std::cout << std::endl;
std::cout << name << std::endl;
float time0 = xtimer->time<float>();
container v;
iterator x;
iterator y;
for ( int i=0; i<size; ++i )
v.push_back(i + 1);
float time1 = xtimer->time<float>();
int sum = 0;
x = v.begin();
y = v.end();
for ( ; x != y; ++x )
sum += *x;
float time2 = xtimer->time<float>();
std::cout << " push_back() " << (time1 - time0) * 1000 << " ms, sum: " <<
sum << std::endl;
std::cout << " iteration " << (time2 - time1) * 1000 << " ms, sum: " <<
sum << std::endl;
}
// ---------------------------------------------------------
// main()
// ---------------------------------------------------------
int main()
{
// create timer object
core::timer* xtimer = core::timer::create();
// profile count
enum { size = 200000 };
profile< std::list<int> >( xtimer,"std::list", size );
profile< core::list<int> >( xtimer,"core::list", size );
profile< std::vector<int> >( xtimer,"std::vector", size );
profile< core::vector<int> >( xtimer,"core::vector",size );
// release timer object
xtimer->release();
}
Here's output from Windows XP Professional SP1 / Athlon64 3000+ / Visual C++
..NET 2003:
std::list
push_back() 32.2217 ms, sum: -1474736480
iteration 2.33968 ms, sum: -1474736480
core::list
push_back() 4.67015 ms, sum: -1474736480
iteration 0.99426 ms, sum: -1474736480
std::vector
push_back() 3.93877 ms, sum: -1474736480
iteration 0.507886 ms, sum: -1474736480
core::vector
push_back() 3.09313 ms, sum: -1474736480
iteration 0.527721 ms, sum: -1474736480
SuSE Linux 9.1 IA32 / Pentium4 1.7Ghz / g++ 3.4.2:
std::list
push_back() 33.382 ms, sum: -1474736480
iteration 2.744 ms, sum: -1474736480
core::list
push_back() 10.964 ms, sum: -1474736480
iteration 2.316 ms, sum: -1474736480
std::vector
push_back() 5.322 ms, sum: -1474736480
iteration 0.71 ms, sum: -1474736480
core::vector
push_back() 4.963 ms, sum: -1474736480
iteration 0.741 ms, sum: -1474736480
The "sum" is just value I compute and cout so that the computation is
forced, also checked the generated assembly code to verify that the code to
do the work was actually ran specified number of times and the result wasn't
computed at compilation time but runtime. Just mention this so that it's
clear what was being measured.
I had fun with this and the experiment is over, actually I did this over a
year ago but recently I read that one article that prompted me to ask the
question so this went back to old code for a moment. ;-)