This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/54393] New: std::getline is almost 10x slower when working on a vstring versus std::string
- From: "bergner at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 28 Aug 2012 18:09:31 +0000
- Subject: [Bug libstdc++/54393] New: std::getline is almost 10x slower when working on a vstring versus std::string
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54393
Bug #: 54393
Summary: std::getline is almost 10x slower when working on a
vstring versus std::string
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bergner@gcc.gnu.org
CC: azanella@linux.vnet.ibm.com
Target: x86_64-linux, powerpc64-linux
Created attachment 28092
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28092
Compressed test input file. Uncompress before using.
The following test case shows that the getline method is almost 10x slower when
reading into a vstring versus into a std::string. This is true on both my
x86_64-linux and powerpc64-linux systems, so this seems to be a implementation
issue rather than a hardware issue.
bergner@otta:~/BUGS$ cat main.cc
#include <iostream>
#include <fstream>
#include <string>
#ifdef VSTR
#include <ext/vstring.h>
typedef __gnu_cxx::__vstring STRING;
#else
typedef std::string STRING;
#endif
int
main(void)
{
std::ifstream f ("test_input");
STRING str;
int max = 0;
while (f)
{
std::getline (f, str);
int len = str.length ();
if (max < len)
max = len;
}
printf ("max length = %d\n", max);
return 0;
}
bergner@otta:~/BUGS$ g++ -O2 -UVSTR main.cc
bergner@otta:~/BUGS$ time ./a.out
max length = 432
real 0m0.257s
user 0m0.120s
sys 0m0.136s
bergner@otta:~/BUGS$ g++ -O2 -DVSTR main.cc
bergner@otta:~/BUGS$ time ./a.out
max length = 432
real 0m1.446s
user 0m1.320s
sys 0m0.120s