On Tue, Jul 10, 2012 at 1:22 PM, Jacob Carlborg <doob@me.com> wrote:
On 2012-07-10 20:53, Brad Anderson wrote:

For what it's worth:

     e = 10_000_000
     a = ((1..e).to_a + (1..e).to_a).sort.uniq.map{ |e| e }

Runs in 21,320 ms on my machine with Ruby 1.9.3 whereas:

     auto end = 10_000_000;
     auto a = chain(iota(1, end), iota(1, end)).array()
                 .sort()
                 .uniq()
                 .map!(n=>n).array();

Runs in 3,057ms with DMD 2.059.  I believe they are largely equivalent
but there is probably room for improvement on both.  I removed
to_s/to!string because I didn't want it allocation bound since we are
talking about algorithm and not the GC or string conversion (with string
conversion the numbers are 28,646ms for Ruby and 14,113ms for D).


For me, using Ruby 1.9.2 and DMD 2.059, D is only just under 10 seconds faster.

--
/Jacob Carlborg



I used -O -inline -noboundscheck -release -d to build.

Regards,
Brad Anderson