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,042 of 33,346   
   Seungbeom Kim to All   
   std::tr1::array performance   
   22 Mar 12 22:05:05   
   
   From: musiphil@bawi.org   
      
   I have a project where I have a std::vector member in a struct.   
   The size N is small (around 3) and fixed, so I don't need it to grow   
   anyway, while it still incurs dynamic allocation for every such object,   
   so I decided to replace it.   
      
   The obvious options are bool[N] and std::tr1::array.   
   The latter supports more convenient assignment and initialization,   
   while for the former I have to write helper functions, so the latter   
   seemed like a (slightly) better choice.   
      
   However, when I measured the performances, I found that the program with   
   std::tr1::array took about 2% (i.e. about a minute) longer than   
   the one with bool[N]. I don't have a lot of samples yet, and I couldn't   
   isolate the issue and make a sample case demonstrating it, but it's still   
   surprising to see such a difference as a possibility.   
      
   Can you think of any reason why std::tr1::array could be slower   
   than bool[N]?   
      
   I'm using gcc 4.4.6 (locally built) with -O3, on Linux.   
      
   --   
   Seungbeom Kim   
      
      
         [ 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