Re: set constructor performance on Visual Studio 2003
On Dec 5, 6:55 pm, "gast...@hotmail.com" <gast...@hotmail.com> wrote:
from Austern's 'Generic Programming and the STL' (9.3.6), one
can read that the set range constructor perfroms NlogN, while
if sorted it can become N. However doing a test the opposite
seems true: using sorted input is always slower:
Set1 insert unsorted 3.297000
Set2 insert sorted 3.500000 //uses a sorted vector a sinput
Set3 insert sorted 1.765000 //uses insert hint
Set4 insert sorted 3.625000 //uses a sorted vector a sinput, but
now reverse
I'm pretty sure that sorted input will only be faster if you
provide the insert hint. Which you can with sorted input, since
you know exactly where the next element is to be placed.
The test is done with code below
I'm not sure what you're measuring here. To start with, what
does DBG_END_TIMER do? And when do you start the timer?
Note too that paging issues may play a role. In such cases,
it's usually best to make a dry run first (to page everything
in), then a large number of runs, taking the average.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]