If I add this import in Noise2DContext.getGradients the run-time decreases a lot (I am now just two times slower than gcc with -Ofast): import core.stdc.math: floor; Bye, bearophile