<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Sat, Jul 25, 2015 at 10:12 PM, Andrei Alexandrescu via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 7/25/15 1:53 PM, Johan Holmberg via Digitalmars-d wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks, my question seems like a carbon copy of the Stack Overflow<br>
article :) Somehow I had missed it when googling.<br>
<br>
I download a dmd 2.068 beta, and re-tried with my input file: now the D<br>
program takes 1.6s (a 10x improvement).<br>
</blockquote>
<br></span>
Great, though it still seems to be behind the C++ version, which is a bummer. -- Andrei<br>
<br>
</blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">My C++ program was actually doing C-style IO via <stdio.h>. I didn't think about the distinction C/C++ when reporting the earlier numbers.</div><div class="gmail_extra"><br></div><div class="gmail_extra">If I switch to full C++ style: <fstream> + <string> + C++ version of getline(), then the C++-solution is even slower than Python: 5.2s. I think it is the C++ libraries of Clang on MacOS Yosemite that are slow.</div><div class="gmail_extra"><br></div><div class="gmail_extra">This prompted me to re-run the tests on a Linux machine (Ubuntu 14.04), still with the same input file, a text file with 7M lines and total size of 466MB:</div><div class="gmail_extra"><div><br></div></div><div class="gmail_extra">C++ with <stdio.h> style IO:    0.40s</div><div class="gmail_extra">C++ with <fstream> style IO:   0.31s</div><div class="gmail_extra">D 2.067                                    1.75s</div><div class="gmail_extra">D 2.068 beta 2:                        0.69s</div><div class="gmail_extra">Perl:                                         1.49s</div><div class="gmail_extra">Python:                                    1.86s</div><div class="gmail_extra"><br></div><div class="gmail_extra">So on Ubuntu, the C++ <fstream> version was clearly best. And the improvement in DMD 2.068 beta "only" a factor of 2.5 from 2.067.</div><div class="gmail_extra"><br></div><div class="gmail_extra">/johan</div></div>