This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/28587] New: vector<bool> is extremely slow (900x slower than it should be)


Compare this trivial program compiled with -DVBOOL and not:

#include <vector>

int main() {
  unsigned N = 100000;
  for (unsigned i = 0; i < 100000; ++i) {
#if VBOOL
    std::vector<bool> V;
    V.resize(N);
#else
    char *X = new char[(N+7)/8];
    memset(X, 0, (N+7)/8);
    delete[] X;
#endif
  }
}

Compiled at -O3 on a 2.5Ghz G5, the -DVBOOL version takes 47.951s, the memset
version takes 0.053s.

This spends all of it's time in std::fill, inserting one bit at a time into the
vector when it resizes.  This is bad and stuff.

-Chris


-- 
           Summary: vector<bool> is extremely slow (900x slower than it
                    should be)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sabre at nondot dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28587


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]