[Haskell-cafe] Performance with do notation, mwc-random and unboxed vector
Malcolm Wallace
malcolm.wallace at me.com
Mon Jun 11 12:17:34 CEST 2012
On 11 Jun 2012, at 10:38, Dmitry Dzhus wrote:
> main = do
> g <- create
> e' <- VU.replicateM count $ standard g
> return ()
In all likelhood, ghc is spotting that the value e' is not used, and that there are no side-effects, so it does not do anything at runtime. If you expand the action argument to replicateM, such that it uses do-notation instead, perhaps ghc can no longer prove the lack of side-effects, and so actually runs the computation before throwing away its result.
When writing toy benchmarks in a lazy language, it is always important to understand to what extent your program _uses_ the data from a generator, or you are bound to get misleading performance measurements.
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list