home bbs files messages ]

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,950 of 33,346   
   alan_mckenney1@this.is.invalid to James K. Lowden   
   Re: Sequence container capacity after ca   
   28 Mar 13 15:17:29   
   
   On Wednesday, March 27, 2013 5:00:02 PM UTC-4, James K. Lowden 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?   
      
      Something else.  I'm saying that, for us, even 30% improvement is   
      worth switching to more cumbersome coding styles, if necessary.   
      
      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.   
      
      By contrast, a variable-length array is allocated on the stack (no   
      heap overhead) and doesn't require us to guess what the maximum   
      size is that we'll need.   
      
      If std::vector::clear() results in a deallocation, we won't use it   
      in the processing phase, either.   
      
      
   > If so, isn't pushing on the efficiency pedal a losing battle?   
   > By squeezing 30%, you don't *avoid* buying the next machine; at best you   
   > just defer it.  By how long, do you reckon?   
      
      By that logic, there's no point to going to the doctor when you're sick,   
      either, since you're only putting off the inevitable.   
      
      
   --   
         [ 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