http://d.puremagic.com/issues/show_bug.cgi?id=3463



--- Comment #52 from Leandro Lucarella <llu...@gmail.com> 2010-07-25 18:45:10 
PDT ---
OK, here is the other side of the coin, a small fabricated benchmark (actually
stolen from the NG, sightly modified by me to make false pointers much more
likely):

// Written by Babele Dunnit <babele.dun...@gmail.com>
// Found at
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=54084
// Sightly modified by Leandro Lucarella <llu...@gmail.com>
// (some readability improvements and output removed)

const IT = 300;
const N1 = 20_000;
const N2 = 40_000;

class Individual
{
        Individual[20] children;
        int[100] data = void;
        this() {
                foreach (i; data)
                        data[i] += (cast(int)&children) - i;
        }
}

class Population
{

        void grow()
        {
                foreach(inout individual; individuals)
                {
                        individual = new Individual;
                }
        }

        Individual[N1] individuals;
}

version = loseMemory;

int main(char[][] args)
{

        Population testPop1 = new Population;
        Population testPop2 = new Population;

        Individual[] indi = new Individual[N1];

        for(int i = 0; i < IT; i++)
        {
                testPop1.grow();
                testPop2.grow();

                version (loseMemory){
                        indi[] = testPop1.individuals ~ testPop2.individuals;
                }

                version (everythingOk){
                        indi[0..N1] = testPop1.individuals;
                        indi[N1..N2] = testPop2.individuals;
                }
        }

        return 0;
}

Here are the results:

Precise:
Maximum resident set size, in Kilobytes = 160192
Elapsed real time, in seconds           = 31.72
(seeing the memory consumption, it was very stable all the time)

Non-precise:
Maximum resident set size, in Kilobytes = 2202400
Elapsed real time, in seconds           = 97.02
(I have to kill it because it was eating up all my memory)

So maybe precise scanning should be configurable (but when not enabled, it
shouldn't store the bitmask in the memory block to avoid the extra heap
space)...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to