[Haskell-cafe] Speed of Error handling with Continuations vs.
Eithers
wren ng thornton
wren at freegeek.org
Thu May 13 04:51:36 EDT 2010
Andrea Vezzosi wrote:
> wren ng thornton wrote:
>> With this change [1] I can't notice any difference for your benchmark[2].
>> Then again, all the runTest calls take 0 msec and I've had no luck making
>> the computation take much time; perhaps your computer can detect a
>> difference.
>
> On my machine, with ghc-6.12.1, yours and the original ErrCPS give
> quite similar results, both ~2x slower than Either.
> However it's important to note that these results are highly dependent
> on the monadic expressions being evaluated, with a different benchmark
> you can get an huge speedup with the CPS versions.
That's very curious. After installing Criterion, my machine (OSX 10.5.8
2.8GHz Intel Core2Duo, GHC 6.12.1 with -O2) shows only 1% difference
between my ErrCPS and Either on this benchmark. Alas, I can't print
kernel density graphs since Crieterion charts are broken on 6.12. It
seems buggy that your platform would behave so much differently...
> mkEMA is in fact quite peculiar, since there's no catchError and the
> throwError call is rarely (or never?) made, and thanks to foldM you
> get that (>>=) is only used in a right associated way, which is the
> ideal situation for Either.
Indeed, mkEMA is a sort of worst-case comparison that doesn't take
advantage of the ability to short-circuit.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list