This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Performance of basic_string::append
- To: libstdc++ at gcc dot gnu dot org
- Subject: Performance of basic_string::append
- From: Ryszard Kabatek <Ryszard dot Kabatek at softax dot pl>
- Date: Fri, 08 Jun 2001 09:42:19 +0200
- Reply-To: Ryszard dot Kabatek at softax dot pl
Hi!
I tested the function basic_string::append (gcc 3.0) in the way,
that I appended an one character string to a string, without
preallocation:
void
test()
{
string s(static_cast<string::size_type>(1) , 'x');
string buf; // no preallocation
for (int i = 0; i < 1000000; ++i)
buf.append(s);
}
It takes 1 hour 41 min. on a PIII/750 (Linux).
-------------
I think the extremly long execution time is caused by the locking mechanism.
Is it really neccessary to turn the locking on in a single-thread program?
Regards
--
Ryszard Kabatek