Implementing and optimizing a simple graph metric
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Tue Sep 24 10:41:49 PDT 2013
On Wednesday, 18 September 2013 at 13:39:29 UTC, bearophile wrote:
> auto centrality =
> minimallyInitializedArray!(typeof(return))(g.vertexCount);
> centrality[] = T0;
> auto stack = new size_t[g.vertexCount];
> auto sigma = minimallyInitializedArray!T(g.vertexCount);
> sigma[] = T0;
> auto delta = minimallyInitializedArray!T(g.vertexCount);
> delta[] = T0;
> auto d = minimallyInitializedArray!long(g.vertexCount);
> d[] = -1;
> auto q = VertexQueue(g.vertexCount);
> auto p = new Appender!(size_t[])[g.vertexCount];
As an experiment I tried something along these lines -- using
uninitializedArray for most of the arrays here and
minimallyInitializedArray for p.
It seems to result in a small speed improvement, although I'm not
certain about that -- certainly not a speed loss.
On the other hand, if inside the VertexQueue implementation, I
replace the "new" declaration with an uninitializedArray call,
the code gets slower by a noticeable amount.
Very odd -- any ideas why that might be?
More information about the Digitalmars-d-announce
mailing list