Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,958 of 33,346    |
|    Francis Glassborow to James K. Lowden    |
|    Re: Sequence container capacity after ca    |
|    30 Mar 13 03:30:10    |
      From: francis.glassborow@btinternet.com              On 29/03/2013 20:30, James K. Lowden wrote:       > On Thu, 28 Mar 2013 15:17:29 -0700 (PDT)       > alan_mckenney1@this.is.invalid wrote:       >       >>> Are you saying vector::operator[] takes 30% more time than a bare       >>> pointer? Or that your program's *overall* performance is 30%       >>> faster if you use C arrays instead of std::vector? Or something       >>> else?       >>       >> Minimizing the frequency of heap allocation and deallocation       >> can gain us at least 30%, so I won't use std::vector as a local       >> variable in the processing phase, because that would mean that       >> each function call results in an allocation and deallocation.       >       > I see. That's an astonishing figure. You really should publish       > what you've learned.       >              Indeed it is. I suspect that the real problem is somewhere else. I       wonder how that figure was measured. It is no good just running a tst       program that does lots of heap allocation/deallocation because real       programs do other things.              Whilst I guess you cannot show the real code would you post:              1) The test programs and methodology you used to come up with that        claim.       2) The general nature of the software being produced.              I am reminded of a something I read a long time ago (back in the 90s)       on optimisation in C++ where the author pointed out that a lazy coding       style with std::string could badly impact on performance. Where       performance mattered it was important to avoid unnecessary copying of       strings (passing by value being just one of the causes of performance       degradation).              Perhaps your code suffers in a similar way (important to pass       std::vector by reference or const reference and only spin off a copy       when actually mutating the original in a context where the original       needs to be maintained.)              Heap allocation/deallocation used to be a serious time consumer, but       AFAIK that problem was largely overcome more than a decade ago.              Francis                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca