[Haskell-cafe] ANNOUNCE: StrictBench 0.1 - Benchmarking code
through strict evaluation
Sterling Clover
s.clover at gmail.com
Mon Jun 8 23:29:54 EDT 2009
On Jun 8, 2009, at 6:58 AM, Magnus Therning wrote:
> Is there no way to force repeated evaluation of a pure value? (It'd
> be nice to be able to perform time measurements on pure code so that
> it's possible to compare Haskell implementations of algorithms to
> implementations in other languages, without running into confounding
> factors.)
This perhaps introduces too much inefficiency, but one trick is to
pack the computation into an existential.
i.e.
calculate :: Floating b => (forall c. Floating c => c) -> b
calculate = id
This method is used to evaluate the same numeric formula with
different rounding modes in ieee-utils.
http://hackage.haskell.org/packages/archive/ieee-utils/0.4.0/doc/html/
src/Numeric-IEEE-Monad.html#perturb
Cheers,
S.
More information about the Haskell-Cafe
mailing list