<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
DMC = Digital Mars Compiler? Does Mingw/GDC uses that? I think that both, g++ and GDC compiled binaries, use the mingw runtime, but I'm not sure also.</blockquote><div><br></div><div>you right, only dmd uses dmc environment, gdc uses mingw's. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br></div>
And I don't think it is I/O bound. It is only around 10MB/s, whereas my HD can do ~100MB/s. Furthermore, on files more compressible, where the speed was higher, the difference between D and C++ was higher too. And if is in fact I/O bound, then D is MORE than 50% slower than C++.</blockquote>
<div><br></div><div>to minimize system load and I/O impact, run the same file in the loop, like 5-10 times, it will be located in kernel cache. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The difference is likely because of differences in external C libraries.<br>
</blockquote></div>
Both, the D and C++ versions, use C's stdio library. What is the difference?<br>
<br>
</blockquote></div>probably because gdc backend make worse job on optimizing D AST vs C++ AST. I've got following results:<div><div><div><br></div><div>C:\D>echo off </div><div>FF=a.doc</div><div>C++ compress a.doc</div>
<div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.36 s.</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.36 s.</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.33 s.</div>
<div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.34 s.</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.34 s.</div><div>"C++ decompress"</div><div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.50 s.</div>
<div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.51 s.</div><div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.51 s.</div><div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.50 s.</div>
<div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.50 s.</div><div>"D compress"</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.11 s.</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.09 s.</div>
<div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.08 s.</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.09 s.</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.08 s.</div>
<div>"D decompress"</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.17 s.</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.19 s.</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.19 s.</div>
<div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.22 s.</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.25 s.</div><div>"Done"</div></div><div><br></div><div>So, what's up? I'm used the same backend too, but DMC (-o -6) vs DMD (-release -inline -O -noboundscheck).</div>
</div><div>I don't know DMC optimization flags, so probably results might be better for it.</div><div><br></div><div>Lets try to compile by MS CL (-Ox)</div><div><div><br></div><div>C:\D>echo off </div><div>FF=a.doc</div>
<div>C++ compress a.doc</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.03 s.</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.02 s.</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.04 s.</div>
<div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.03 s.</div><div>a.doc (2694428 bytes) -> a.doc.cmp (1459227 bytes) in 1.01 s.</div><div>"C++ decompress"</div><div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.08 s.</div>
<div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.06 s.</div><div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.07 s.</div><div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.07 s.</div>
<div>a.doc.cmp (1459227 bytes) -> a.doc.cmp.or (2694428 bytes) in 1.07 s.</div><div>"D compress"</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.08 s.</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.09 s.</div>
<div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.09 s.</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.09 s.</div><div>a.doc (2694428 bytes) -> a.doc.dmp (1459227 bytes) in 1.09 s.</div>
<div>"D decompress"</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.15 s.</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.17 s.</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.19 s.</div>
<div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.17 s.</div><div>a.doc.dmp (1459227 bytes) -> a.doc.dmp.or (2694428 bytes) in 1.17 s.</div><div>"Done"</div></div><div><br></div><div>Much better for C++, but D is not so worse and about 1.1*C++ too.</div>
<div><br></div><div>What we see - different compiler, different story. We should not compare languages for performance but compilers!</div><div>So many differencies in compilers and environment and definetelly C++ is much more mature for performance now but also D has own benefits (faster development/debugging and more reliable code).</div>
<div><br></div><div>Thanks,</div><div>Oleg.</div><div>PS. BTW, this code still can be optimized quite a lot.</div>