[Haskell-cafe] forLoop + strict State monad is much faster than foldl'

Niklas Hambüchen mail at nh2.me
Thu May 1 17:40:47 UTC 2014


Nice find, I merged your benchmark addition.

Would you mind making a GHC issue from your `enumFromTo` findings?

On 01/05/14 15:17, Patrick Wheeler wrote:
> @Niklas
> 
> You can use the `foldM` form the FoldL package to achieve equal results
> as the fastest loops in your current benchmark. foldM will allow you to
> deal with your loops at a high level of abstraction though. See the
> following post, by Gabriel Gonzalez, for an example:
> http://www.haskellforall.com/2013/08/foldl-100-composable-streaming-and.html
> 
> I have added the bench mark to my fork of your repo, and made a pull
> request:
> https://github.com/Davorak/loop
> 
> It looks like the only reason that `foldM` does not preform well with
> `Word32` is because of the naive implementation of `enumFromTo` for
> Word32 as explained in my other email in more detail.
> 
> Here is the Criterion report:
> http://htmlpreview.github.io/?https://github.com/Davorak/loop/blob/master/results/bench.html


More information about the Haskell-Cafe mailing list