On Tuesday, 3 October 2017 at 14:07:39 UTC, SrMordred wrote:
On Tuesday, 3 October 2017 at 13:53:38 UTC, rikki cattermole wrote:
Be warned, x86 cpu's today are not like they were 10 years ago. A good portion of a symbol could be full of nop's and it could end up being faster than the one without them.

Next, compare against ldc, not gdc primarily. Its better maintained and ugh more inline with dmd (its a bit of a mess, lets not go there). Of course nothing wrong with doing both.

std.container.* is basically dead. We need to replace it. We are currently waiting on std.experimental.allocators before going much more further (also a lot of other no-gc stuff).

Compare (on https://d.godbolt.org/ with "ldc -O3" and "gdc -O3"):
---
auto test1(int[] arr, int cmp)
{
    int[] r;
    foreach(v ; arr)
      if(v == cmp)r~=v;
    return r;
}

import std.container.array;
auto test2(ref Array!int arr, int cmp)
{
    Array!int r;
    foreach(v ; arr)
      if(v == cmp)r.insert(v);
    return r;
}
---
With ldc the results are similar.
5k+
And I know, im not into performance comparison yet. But you know, less code, more cache friendly (and sometimes better performance).


Well -O3 does not generate cache friendly assembly anyway. For instance, inlining functions regardless of cost.

I'd take the assembly count with a pinch of salt when you are using templated code.

Iain


Reply via email to