What does it cost to try?

Discussion in 'C++' started by Steven T. Hatton, Aug 6, 2004.

  1. What is the runtime cost of wrapping a function call in a try/catch? I
    assume it's something like an if/else when it goes on the stack. I believe
    that means an additional compare and an additional memory location to
    branch to. Would this be significant enough to make a difference between
    say putting the try{}catch{} inside the body of a loop as opposed to
    wrapping the loop in the try/catch?
    --
    STH
    Hatton's Law: "There is only One inviolable Law"
    KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
    Mozilla: http://www.mozilla.org
     
    Steven T. Hatton, Aug 6, 2004
    #1
    1. Advertising

  2. Steven T. Hatton

    David Hilsee Guest

    "Steven T. Hatton" <> wrote in message
    news:...
    > What is the runtime cost of wrapping a function call in a try/catch? I
    > assume it's something like an if/else when it goes on the stack. I

    believe
    > that means an additional compare and an additional memory location to
    > branch to. Would this be significant enough to make a difference between
    > say putting the try{}catch{} inside the body of a loop as opposed to
    > wrapping the loop in the try/catch?


    This is obviously implementation-dependent. The g++ compiler even offers
    flags to control the "cost" of using exceptions
    (http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Exception-Handling-Control.html)
    .. You might get better answers in a newsgroup that discusses your
    implementation.

    --
    David Hilsee
     
    David Hilsee, Aug 6, 2004
    #2
    1. Advertising

  3. Steven T. Hatton

    David Hilsee Guest

    "David Hilsee" <> wrote in message
    news:...
    > "Steven T. Hatton" <> wrote in message
    > news:...
    > > What is the runtime cost of wrapping a function call in a try/catch? I
    > > assume it's something like an if/else when it goes on the stack. I

    > believe
    > > that means an additional compare and an additional memory location to
    > > branch to. Would this be significant enough to make a difference

    between
    > > say putting the try{}catch{} inside the body of a loop as opposed to
    > > wrapping the loop in the try/catch?

    >
    > This is obviously implementation-dependent. The g++ compiler even offers
    > flags to control the "cost" of using exceptions
    >

    (http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Exception-Handling-Control.html)
    > . You might get better answers in a newsgroup that discusses your
    > implementation.


    Sorry, I linked to an Ada compiler, but the message is still the same.

    --
    David Hilsee
     
    David Hilsee, Aug 6, 2004
    #3
    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,860
    bienwell
    May 27, 2005
  2. Duane Morin

    Does 'match' cost performance?

    Duane Morin, Sep 14, 2003, in forum: XML
    Replies:
    6
    Views:
    452
    Scott Raymond
    Sep 16, 2003
  3. Teddy
    Replies:
    4
    Views:
    347
    Jaspreet
    Jul 5, 2005
  4. Tiglath
    Replies:
    5
    Views:
    415
    peter koch
    Jan 20, 2007
  5. Reportor

    What CPU/Memory does a Wait cost?

    Reportor, Dec 17, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    96
    Reportor
    Dec 17, 2003
Loading...

Share This Page