[Issue 19617] New: [2.085a] Much slower code compared to 2.084

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 26 11:03:57 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19617

          Issue ID: 19617
           Summary: [2.085a] Much slower code compared to 2.084
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

I wanted to test something and took this code from the dlang tour:

---
// Hey come on, just get the whole army!
import std.algorithm : canFind, map,
  filter, sort, uniq, joiner, chunkBy, splitter;
import std.array : array, empty;
import std.range : zip;
import std.stdio : writeln;
import std.string : format;
import std.datetime.stopwatch;

void main()
{
    StopWatch sw;
    sw.start;
    string text = q{This tour will give you an
overview of this powerful and expressive systems
programming language which compiles directly
to efficient, *native* machine code.};

    alias pred = c => canFind(" ,.\n", c);
    auto words = text.splitter!pred
      .filter!(a => !a.empty);
    auto wordCharCounts = words
      .map!"a.count";

    zip(wordCharCounts, words)
      .array()
      .sort()
      .uniq()
      .chunkBy!(a => a[0])
      .map!(chunk => format("%d -> %s",
          chunk[0],
          chunk[1]
            .map!(a => a[1])
            .joiner(", ")))
      .joiner("\n")
      .writeln();
      writeln(sw.peek);
}
---

- dmd args : -O -release -inline -boundscheck=off
- exe generated with DMD 2.084 takes on average 110 µs
- the one with DMD ~master (aa0c2062499419cc933f9bbf94cf88ec3244e2f9) takes on
average 145 µs.

Note that the same difference is observed without any DMD arg at all.

--


More information about the Digitalmars-d-bugs mailing list