Why is std.algorithm so complicated to use?

Jacob Carlborg doob at me.com
Tue Jul 10 12:22:27 PDT 2012


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




More information about the Digitalmars-d mailing list