Re: try/catch performance

Discussion in 'Java' started by EnKan, Aug 23, 2003.

  1. EnKan

    EnKan Guest

    "Dan Peder Eriksen" <> wrote in message news:<wwM%a.14549$>...
    > "EnKan" <> wrote in message
    > news:...
    > > I'm not sure that I may have interpreted correctly the
    > > wording of the author who implied this, but is it true
    > > that a piece of code that is encapsulated within a try block
    > > executes very slowly compared to one that is NOT ?
    > >
    > > I have been of the belief that it is when, and only when,
    > > an exception actually occurs that the "handling" of the exception
    > > is probably expensive.
    > >
    > > Would someone please clarify !
    > >
    > > TIA , (and sorry for the duplicate post if there happens to
    > > be one)

    >
    > Code that's inside a try block doesn't execute slowly.
    > What's slow is creating an Exception(throw new Exception("some exception")).
    > This is because the exception has to get the stacktrace and this takes time.
    >
    > Dan


    Thanks very much for the clarification.

    I'm trying to get all my facts about try/catch impact on performance,
    if any. Is it a fact that a method containing a try/catch block
    will NOT be inlined ? Also, if I'm invoking a method within a
    try block which in turn would invoke other methods, but none
    of which of those contain any try/catch blocks, then would there
    be any inlining problems at all (w.r.t try/catch) ?

    Thanks for your patience.
     
    EnKan, Aug 23, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bienwell
    Replies:
    4
    Views:
    3,856
    bienwell
    May 27, 2005
  2. John Salerno
    Replies:
    20
    Views:
    859
    John Salerno
    Aug 11, 2006
  3. Efi Merdler

    Does try...catch affects performance

    Efi Merdler, Mar 8, 2007, in forum: Java
    Replies:
    12
    Views:
    1,600
    Joshua Cranmer
    Mar 10, 2007
  4. Fabio Z Tessitore

    who is simpler? try/except/else or try/except

    Fabio Z Tessitore, Aug 12, 2007, in forum: Python
    Replies:
    5
    Views:
    378
  5. =?Utf-8?B?QUo=?=

    When to TRY and not to TRY

    =?Utf-8?B?QUo=?=, Oct 16, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    330
    sloan
    Oct 17, 2007
Loading...

Share This Page