[Haskell-cafe] Foreign function performance: monadic vs pure
Gregory Collins
greg at gregorycollins.net
Mon Apr 11 20:36:01 CEST 2011
On Mon, Apr 11, 2011 at 3:55 PM, Serguei Son <serguei.son at gmail.com> wrote:
> So if I must use a safe function returning IO a,
> there is no way to improve its performance? To give you
> a benchmark, calling gsl_ran_ugaussian a million times
> in pure C takes only a second or two on my system.
In the C version, are you also producing a linked list containing all
of the values? Because that's what mapM does. Your test is mostly
measuring the cost of allocating and filling ~3 million machine words
on the heap. Try mapM_ instead.
G
--
Gregory Collins <greg at gregorycollins.net>
More information about the Haskell-Cafe
mailing list