<div dir="rtl"><div dir="ltr">Hi Chandler, </div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">First let me say your GoingNative 2013 talk was very interesting. There is lots of potential in improving the efficiency and reliability of C++ programming, especially with the new feature in C++ 11. One has to de-program old habits to use these features.</div>
<div dir="ltr"><br></div></div><div dir="ltr">To the subject, I did not meaure times exactly since the effect was very noticable for a trivial test program, three times as slow!</div><div dir="ltr"><br></div><div dir="ltr">
Here are the combinations I tested:</div><div dir="ltr"><br></div><div dir="ltr">clang + libcxx iostream = about 3 seconds</div><div dir="ltr">clang + libstdc++ iostream = about 1 second</div><div dir="ltr">clang + libc stdio.h = about 1 second</div>
<div dir="ltr"><br></div><div dir="ltr">gcc + libcxx iostream = about 3 seconds</div><div dir="ltr">gcc + libstdc++ iostream = about 1 second</div><div dir="ltr">gcc + libc stdio.h = about 1 second</div><div dir="ltr"><br>
</div><div dir="ltr">clang.exe is from <a href="http://llvm.org/builds/">http://llvm.org/builds/</a>, gcc is MingW-builds 4.8.1 32 bit.<br></div><div dir="ltr"><br></div><div dir="ltr">For clang + libcxx the command was:</div>
<div dir="ltr"><br></div><div dir="ltr"><font face="courier new, monospace">clang main.cpp -nostdinc -I../libcxx -I../mingw-4.8.1 -target i686-pc-mingw32 -Wno-deprecated-register -Wno-ignored-attributes libc++.dll.a libc++abi.dll.a -o main.exe<br>
</font></div><div dir="ltr"><br></div><div dir="ltr">For clang + libstdc++ the command was:</div><div dir="ltr"><br></div><div dir="ltr"><font face="courier new, monospace">clang main.cpp -nostdinc -I../libstdc -I../libstdc/i686-w64-mingw32 -I../mingw-4.8.1 -target i686-pc-mingw32 -Wno-deprecated-register -Wno-ignored-attributes libstdc++.dll.a -o main.exe<br>
</font></div><div dir="ltr"><br></div><div dir="ltr">For gcc + libstdc++ the command was:</div><div dir="ltr"><br></div><div dir="ltr"><font face="courier new, monospace">gcc main.cpp -lstdc++<br></font></div><div dir="ltr">
<br></div><div dir="ltr">For gcc + libcxx the command was:</div><div dir="ltr"><br></div><div dir="ltr"><font face="courier new, monospace">gcc main.cpp -std=c++11 -nostdinc -I../libcxx -I../libstdc/i686-w64-mingw32 -I../mingw-4.8.1 -lstdc++ libc++.dll.a libc++abi.dll.a<br>
</font></div><div dir="ltr"><br></div><div dir="ltr">These results were repeatable when running mutiple times.</div><div dir="ltr"><br></div><div dir="ltr">The iostream code is:</div><div dir="ltr"><br></div><div dir="ltr">
<div dir="ltr"><font face="courier new, monospace">#include <iostream></font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace">int main() {</font></div>
<div dir="ltr"><font face="courier new, monospace"> std::cout<<"hello cout\n";</font></div><div dir="ltr"><font face="courier new, monospace"> return 0;</font></div><div dir="ltr"><font face="courier new, monospace">}</font></div>
<div><br></div><div>The stdio.h code is:</div><div><br></div><div><div><font face="courier new, monospace">#include <stdio.h></font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">int main() {</font></div>
<div><font face="courier new, monospace"> printf("hello printf\n");</font></div><div><font face="courier new, monospace"> return 0;</font></div><div><font face="courier new, monospace">}</font></div></div><div>
<br></div><div>The headers used with gcc are the defaults.</div><div>The headers used for clang are libcxx or libstdc++ for C++ and MingW 4.8.1 for the C library.</div><div><br></div><div>So when compiling small modules, libcxx slows down compilation considerably compared with including libstdc++. </div>
<div><br></div><div>Yaron<br></div></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div class="gmail_extra"><div dir="ltr"><br><br><div class="gmail_quote">2013/10/2 Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra"><div class="im">On Wed, Oct 2, 2013 at 6:16 AM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>></span> wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">For example, including iostream also includes:</div>
<div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">
iostream:38:</div><div dir="ltr">ios:216:</div><div dir="ltr">__locale:15:</div><div dir="ltr">
string:439:</div><div dir="ltr">algorithm:627:</div><div dir="ltr">memory:603:</div><div dir="ltr">tuple</div><div><br></div><div>That's tons of baggage which slows down compilation significantly.</div></div></blockquote>
</div><br></div>Have you measured it? Especially for non-trivial translation units? I have tried, and been unable to measure significant (> 5%) changes by minimizing standard library includes.</div><div class="gmail_extra">
<br>
</div><div class="gmail_extra">Also, we're working on C++ modules which will largely eliminate *any* cost associated with "bundling" together N different headers as part of a library.</div></blockquote></div>
</div></div></div>