Re: STL container question
Ioannis Vranos wrote:
Hendrik Schober wrote:
Ioannis Vranos wrote:
Hendrik Schober wrote:
Ioannis Vranos wrote:
[...]
We must think generally. In general, sorting a list is faster than
sorting a vector, because the list sorting does not involve the
construction or destruction of any object.
Regarding ints, I think sorting a vector of ints and as list of
ints, both have about the same efficiency.
Why don't you just measure before you doubt the statements
of those who already went and did this?
On my platform, this
[ Non-portable code...]
and thus again disagrees with you.
Eagerly awaiting your counter example,
[code]
I had to add another zero in order to get sensible results:
Creating vector with 100000 elements... Done!
Filling list with vector elements... Done!
Timing the sorting of the vector... Done!
Timing the sorting of the list... Done!
The sorting of the vector took 0.016 seconds
The sorting of the list took 0.468 seconds
Your computer is faster than mine and probably with more RAM.
In my computer with SIZE 10000:
john@john-desktop:~/Projects/src$ ./foobar_cpp
Creating vector with 10000 elements... Done!
Filling list with vector elements... Done!
Timing the sorting of the vector... Done!
Timing the sorting of the list... Done!
The sorting of the vector took 2.55 seconds
The sorting of the list took 0.02 seconds
john@john-desktop:~/Projects/src$
In my computer with SIZE 100000 (uses swap):
john@john-desktop:~/Projects/src$ ./foobar_cpp
Creating vector with 100000 elements... Done!
Filling list with vector elements... Done!
Timing the sorting of the vector... Done!
Timing the sorting of the list... Done!
The sorting of the vector took 27.46 seconds
The sorting of the list took 4.58 seconds
john@john-desktop:~/Projects/src$
==> The timings less than 1 second are not conclusive. Add 0s until you
exceed 1-2 seconds.
This exercise is pointless. I made 200K elements (no swap, but the
computer uses up to 2.5G of RAM, probably mostly due to the need to keep
all the pointers in the list elements) and I still consistently get
Creating vector with 200000 elements... Done!
Filling list with vector elements... Done!
Timing the sorting of the vector... Done!
Timing the sorting of the list... Done!
The sorting of the vector took 0.015 seconds
The sorting of the list took 0.156 seconds
What is it you're trying to prove? That your computer and your
implementation are dilapidated? Get a better compiler.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask