News for hackers. Stuff that matters.
Re:Measuring execution performance of C++ exceptions vs. err... by maxpolun on Monday January 09, 2017 @09:35AM (#13356541)
I wonder what the performance difference is when you're actually handling the errors though. I'd imagine that

    try {
       doThing();
    } catch (Exception1 e) {
        handleError1();
    } catch (Exception2 e) {
        handleError2();
    } catch (Exception3 e) {
        handleError3();
    }
Might be slower than

    Error err = doThing();
    if (err.code === ERROR1) {
        handleError1();
    } else if (err.code === ERROR2) {
        handleError2();
    } else if (err.code === ERROR3) {
        handleError3();
    }
Exceptions are best in my mind when they are very coarsely-grained, and error-codes best when you need to handle very fine-grained errors. This is certainly true in the code ergonomics, but I'd be interested in seeing if it's true for performance as well.

There are no comments on this comment yet.