Haskell

bearophile bearophileHUGS at lycos.com
Thu Aug 25 10:40:38 PDT 2011


Timon Gehr:

> http://pastebin.com/C6vf9DQQ

Very good.


> It delivers correct results, but it takes 20min to run. (probably mainly 
> GC-related, I don't know)

DMD is not inlining those delegates, it is not merging streams as GHC does, etc. But such missing optimizations aren't the main cause of that so low performance. I think following those chains is a kind of worst-case for a mark&sweep GC. If I disable the GC using this code:


void main() {
    import core.memory, core.stdc.stdlib;
    auto h = hamming!BigInt();
    GC.disable();
    writeln(h()[1_000_000]);
    exit(0);
}


The code runs in less than 23 seconds, using about 1.5 GB RAM, on a slow 32 bit PC (timings on a 64 CPU are welcome). Later I'll profile the code.

Bye,
bearophile


More information about the Digitalmars-d mailing list