You can check if disabling the GC just before the insert process improves the performance. You may see 3x performance improvement. Disabling is safe provided you re-enable, this can be done reliably with scope(exit) or something similar.

import core.memory;

// ...


void main ()
{
        auto f = new container ();
        element.postblit_counter = 0;
        GC.disable;
        foreach (i; 0..LIMIT)
        {
                f.insert (element (i));
        }
        GC.enable;
        writefln ("%s", element.postblit_counter);
}

--rt

Reply via email to