On Saturday, 11 April 2015 at 12:04:06 UTC, matovitch wrote:
well ldc doesn't compile :

kmeans.d(40): Error: no property 'enumerate' for type 'Range'

With -O -release -inline I get around 2s with foreach and 0.5s with a simple for.

LDC does not yet support the 2.067 front-end version in which `enumerate` was made available. You could get the `enumerate` implementation from the DMD release and it should work with older FE versions (within reason - it may or may not depend on relatively new language features).

Performance with range-based code requires a sophisticated optimizer, the kind that is used to optimize idiomatic C++ code. In particular, inlining is important as there are a lot of tiny generic functions involved. Unfortunately, DMD's optimizer is not up to this task.

Reply via email to