On Tue, Jul 10, 2012 at 1:22 PM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 2012-07-10 20:53, Brad Anderson wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For what it's worth:<br>
<br>
     e = 10_000_000<br>
     a = ((1..e).to_a + (1..e).to_a).sort.uniq.map{ |e| e }<br>
<br>
Runs in 21,320 ms on my machine with Ruby 1.9.3 whereas:<br>
<br>
     auto end = 10_000_000;<br>
     auto a = chain(iota(1, end), iota(1, end)).array()<br>
                 .sort()<br>
                 .uniq()<br>
                 .map!(n=>n).array();<br>
<br>
Runs in 3,057ms with DMD 2.059.  I believe they are largely equivalent<br>
but there is probably room for improvement on both.  I removed<br>
to_s/to!string because I didn't want it allocation bound since we are<br>
talking about algorithm and not the GC or string conversion (with string<br>
conversion the numbers are 28,646ms for Ruby and 14,113ms for D).<br>
<br>
</blockquote>
<br></div>
For me, using Ruby 1.9.2 and DMD 2.059, D is only just under 10 seconds faster.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
/Jacob Carlborg<br>
<br>
<br>
</font></span></blockquote></div><br><div>I used -O -inline -noboundscheck -release -d to build.</div><div><br></div><div>Regards,</div><div>Brad Anderson</div>