Re: Real life cost of using exceptions for control flow?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 06/11/04

  • Next message: Jerry Pisk: "Re: Real life cost of using exceptions for control flow?"
    Date: Fri, 11 Jun 2004 21:23:00 +0100
    
    

    Frank Hileman <frankhil@no.spamming.prodigesoftware.com> wrote:
    > This test cannot be generalized to all exception performance problems. We
    > found exceptions thrown by System.Drawing during a display pass caused such
    > a dramatic slow-down that we wrote elaborate code to avoid exceptions. It
    > could be that exceptions thrown by unmanaged code wrappers are unusually
    > slow. In general, the only way to determine the extent of the problem is to
    > test on your own code.
    >
    > This is why the .NET design guidelines recommend avoiding exceptions for
    > expected or common error conditions. Throwing exceptions during drawing
    > operations, for example, should never be acceptable, since it causes so many
    > problems. For us, the difference was a smooth display, versus an unusable
    > display.

    Well, I'm not sure that's really the reason - I suspect it's really
    because using exceptions for normal control flow makes code harder to
    follow. Performance is an issue, but I don't think it's the main one.

    Certainly 200 exceptions an hour isn't going to affect most
    applications at all.

    -- 
    Jon Skeet - <skeet@pobox.com>
    http://www.pobox.com/~skeet
    If replying to the group, please do not mail me too
    

  • Next message: Jerry Pisk: "Re: Real life cost of using exceptions for control flow?"

    Relevant Pages

    • Re: Displaying messages/errors to users. Opinions?
      ... > I have been working on a few ASP.NET applications recently that access ... Likewise if an error occurs then I would like to display ... What I do is to set a couple of Session variables when I want a message to ... You don't really want the user to see the Message text of system exceptions, ...
      (microsoft.public.dotnet.framework.aspnet.webcontrols)
    • Re: Displaying messages/errors to users. Opinions?
      ... > I have been working on a few ASP.NET applications recently that access ... Likewise if an error occurs then I would like to display ... What I do is to set a couple of Session variables when I want a message to ... You don't really want the user to see the Message text of system exceptions, ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Can u protect cells in Word as in Excel from unauthorised chan
      ... Please note that the "Exceptions " will not display until you click ... If you are using Word 2003 you could consider using the Protect Document ...
      (microsoft.public.word.tables)
    • Re: Dynamic Illuminated Text on Vehicles
      ... display on his vehicle which slowly alternated between two panels. ... was told that (subject to exceptions not relevant to what he was ... The Road Vehicle Lighting Regulations 1989 reg 13 was quoted. ...
      (uk.legal)
    • Re: Real life cost of using exceptions for control flow?
      ... found exceptions thrown by System.Drawing during a display pass caused such ... a dramatic slow-down that we wrote elaborate code to avoid exceptions. ... For us, the difference was a smooth display, versus an unusable ... >> If you have a lot of cleanup and deallocations in the catch block, ...
      (microsoft.public.dotnet.framework.performance)