stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ravi Inampudi" <inamp...@roguewave.com>
Subject ostringstream performance
Date Fri, 11 Aug 2006 22:00:41 GMT

Hello,

I have a customer using the ostringstream who is running the following test case which is
taking more than twice the amount between SourcePro ed 4 and ed 7. I also tried with ed 9
and found the performance a little better than ed 7 but still slower. Using quantify, the
possible source of the slowdown seem to happen in include/streambuf.cc, xsputn()'s for loop
.  Any known issues?  Timing results are shown below.

Ravi


// test_portal.cpp

#include <string>
#include <sstream>

// 8 char str
static const char test_str[] = "8 chars ";
std::string teststr(test_str);

void appendStreamTest()
{
  std::ostringstream strm;
  for (int i = 0; i < 256; i++)
  {
    strm << teststr;
  }
  std::string str = strm.str();
}

int main()
{
  for (int i = 0; i < 10000; i++)
  {
    appendStreamTest();
  }
  return 0;
}


1. SourcePro ed9:sol10:studio10 

time test_portal

real    0m7.01s
user    0m6.83s
sys     0m0.02s

2. SourcePro ed7:sol9:studio8

time test_portal

real    0m8.95s
user    0m8.81s
sys     0m0.04s

3. SourcePro ed4:sol8:studio7 

time test_portal

real    0m3.13s
user    0m3.11s
sys     0m0.02s

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message