On Mon, Sep 14, 2015 at 02:34:41PM +0000, Fredrik Boulund via Digitalmars-d-learn wrote: > On Monday, 14 September 2015 at 14:18:58 UTC, John Colvin wrote: > >Range-based code like you are using leads to *huge* numbers of > >function calls to get anything done. The advantage of inlining is > >twofold: 1) you don't have to pay the cost of the function call > >itself and 2) often more optimisation can be done once a function is > >inlined. > > Thanks for that explanation! Now that you mention it it makes perfect > sense. I never considered it, but of course *huge* numbers of > function calls to e.g. next() and other range-methods will be made. > > >Because there are much better at inlining. dmd is quick to compile > >your code and is most up-to-date, but ldc and gdc will produce > >somewhat faster code in almost all cases, sometimes very dramatically > >much faster. > > Sure sounds like I could have more fun with LDC and GDC on my system > in addition to DMD :).
If performance is a problem, the first thing I'd recommend is to use a profiler to find out where the hotspots are. (More often than not, I have found that the hotspots are not where I expected them to be; sometimes a 1-line change to an unanticipated hotspot can result in a huge performance boost.) The next thing I'd try is to use gdc instead of dmd. ;-) IME, code produced by `gdc -O3` is at least 20-30% faster than code produced by `dmd -O -inline`. Sometimes the difference can be up to 40-50%, depending on the kind of code you're compiling. T -- Lottery: tax on the stupid. -- Slashdotter
