This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

Performance of basic_string::append


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


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