[llvm-bugs] [Bug 33840] New: std::string::push_back is 3.4x slower than on libstdc++

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 18 14:21:13 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33840

            Bug ID: 33840
           Summary: std::string::push_back is 3.4x slower than on
                    libstdc++
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: thomasanderson at google.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Simple program that demonstrates the issue:
----test.cpp----
#include <string>

int main(void) {
  std::string s;
  for(volatile int i = 0; i < 500000000; i++) {
    s.push_back('a');
  }
  return 0;
}
----test.cpp----

$ clang++ main.cpp -stdlib=libstdc++ && time ./a.out
real    0m2.451s
$ clang++ main.cpp -stdlib=libc++ && time ./a.out
real    0m8.535s

I've verified that it is always a constant factor of 3.4x slower than libstdc++
regardless of the input size.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170718/351a1971/attachment.html>


More information about the llvm-bugs mailing list