This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/28587] New: vector<bool> is extremely slow (900x slower than it should be)
- From: "sabre at nondot dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Aug 2006 18:17:35 -0000
- Subject: [Bug libstdc++/28587] New: vector<bool> is extremely slow (900x slower than it should be)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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