[Haskell-cafe] Speed of Error handling with Continuations vs. Eithers

Andrea Vezzosi sanzhiyan at gmail.com
Thu May 13 09:58:43 EDT 2010


On Thu, May 13, 2010 at 10:51 AM, wren ng thornton <wren at freegeek.org> wrote:
> 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...

I got the measurements from the original code, could you share the
code that uses criterion instead?

>> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list