Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > perfomance penalty in using execption handling..

Reply
Thread Tools

perfomance penalty in using execption handling..

 
 
A. Saksena
Guest
Posts: n/a
 
      09-10-2004
Hi,
Do anybody have an idea of the performance penalty while using exception
handling (specially with g++)

Abhishek


 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      09-10-2004
A. Saksena wrote:

> Do anybody have an idea of the performance penalty while using exception
> handling (specially with g++)


Can you write a few functions, call them 10,000 times, time test them, and
run them with and without exception handling turned on in the compiler?

(And why do you need performance?)

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


 
Reply With Quote
 
 
 
 
void
Guest
Posts: n/a
 
      09-10-2004
A. Saksena wrote:
> Hi,
> Do anybody have an idea of the performance penalty while using exception
> handling (specially with g++)


I've done some small tests you can look at it here:
http://3miasto.net/~chq/c/carray.txt

Best
Darek
 
Reply With Quote
 
Jesper Madsen
Guest
Posts: n/a
 
      09-10-2004
http://www.codeproject.org/cpp/excep...asp#xx515459xx
lots of compilers do not pay any performance penalty, unless an exception
is thrown... So if you code that way, that exceptions are truly exceptional,
you should
have no penalty...
" A. Saksena" <(E-Mail Removed)> wrote in message
news:chsdl5$f4e$(E-Mail Removed)...
> Hi,
> Do anybody have an idea of the performance penalty while using exception
> handling (specially with g++)
>
> Abhishek
>
>



 
Reply With Quote
 
Steven T. Hatton
Guest
Posts: n/a
 
      09-10-2004
Jesper Madsen wrote:

> http://www.codeproject.org/cpp/excep...asp#xx515459xx
> lots of compilers do not pay any performance penalty, unless an exception
> is thrown... So if you code that way, that exceptions are truly
> exceptional, you should
> have no penalty...


"For this discussion, I will consider exceptions to be those that are
explicitly thrown or occur due to conditions like divide by zero or null
pointer access."

C++ programmers catching null pointer exceptions? I'll let you know when I
stop laughing.

--
"[M]y dislike for the preprocessor is well known. Cpp is essential in C
programming, and still important in conventional C++ implementations, but
it is a hack, and so are most of the techniques that rely on it. ...I think
the time has come to be serious about macro-free C++ programming." - B. S.

 
Reply With Quote
 
Peter Koch Larsen
Guest
Posts: n/a
 
      09-11-2004

"Steven T. Hatton" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed)...
>
> "For this discussion, I will consider exceptions to be those that are
> explicitly thrown or occur due to conditions like divide by zero or null
> pointer access."
>
> C++ programmers catching null pointer exceptions? I'll let you know when

I
> stop laughing.
>


Visual C++ in its standard configuration allow null-pointer exceptions to be
catched, so there's not really much to laugh at. And if you continue your
laughs, I can tell you that this is completely compliant.

Apart from that, the link seems to be about what Microsoft calls "structured
exception handling" (a bit like Unix signals). I only skimmed that page,
however.

/Peter


 
Reply With Quote
 
Old Wolf
Guest
Posts: n/a
 
      09-12-2004
"Peter Koch Larsen" <(E-Mail Removed)> wrote:
> "Steven T. Hatton" <(E-Mail Removed)> skrev i en meddelelse:

(whatever that means)
> >
> > "For this discussion, I will consider exceptions to be those that are
> > explicitly thrown or occur due to conditions like divide by zero or null
> > pointer access."
> >
> > C++ programmers catching null pointer exceptions?
> > I'll let you know when I stop laughing.

>
> Visual C++ in its standard configuration allow null-pointer
> exceptions to be catched,


Null pointer accesses don't generate an exception.
Maybe you mean that Visual C++ generates an exception for null-pointer
accesses?

> And if you continue your laughs, I can tell you that this is
> completely compliant.


This means it would have to check every single pointer
access (and every division, if it also generates exceptions for
divide-by-zero), so in the context of the OP's question
"what overhead?", the answer would have to be "a lot".
 
Reply With Quote
 
Peter Koch Larsen
Guest
Posts: n/a
 
      09-13-2004

"Old Wolf" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed) om...
> "Peter Koch Larsen" <(E-Mail Removed)> wrote:
> > "Steven T. Hatton" <(E-Mail Removed)> skrev i en meddelelse:

> (whatever that means)
> > >
> > > "For this discussion, I will consider exceptions to be those that are
> > > explicitly thrown or occur due to conditions like divide by zero or

null
> > > pointer access."
> > >
> > > C++ programmers catching null pointer exceptions?
> > > I'll let you know when I stop laughing.

> >
> > Visual C++ in its standard configuration allow null-pointer
> > exceptions to be catched,

>
> Null pointer accesses don't generate an exception.
> Maybe you mean that Visual C++ generates an exception for null-pointer
> accesses?
>
> > And if you continue your laughs, I can tell you that this is
> > completely compliant.

>
> This means it would have to check every single pointer
> access (and every division, if it also generates exceptions for
> divide-by-zero), so in the context of the OP's question
> "what overhead?", the answer would have to be "a lot".


No - you are misunderstanding my post - especially the part you snipped

I am saying that one legal behaviour of dereferencing a null pointer is to
throw an exception. This is so because the behaviour in this case - and
other cases of this nature - is unspecified: anything can happen.

/Peter


 
Reply With Quote
 
Old Wolf
Guest
Posts: n/a
 
      09-13-2004
"Peter Koch Larsen" <(E-Mail Removed)> wrote:
> "Old Wolf" <(E-Mail Removed)> skrev i en meddelelse:
> > "Peter Koch Larsen" <(E-Mail Removed)> wrote:
> > > "Steven T. Hatton" <(E-Mail Removed)> skrev i en meddelelse:
> > > >
> > > > "For this discussion, I will consider exceptions to be those that are
> > > > explicitly thrown or occur due to conditions like divide by zero or

> null
> > > > pointer access."
> > > >
> > > > C++ programmers catching null pointer exceptions?
> > > > I'll let you know when I stop laughing.
> > >
> > > Visual C++ in its standard configuration allow null-pointer
> > > exceptions to be catched,

> >
> > Null pointer accesses don't generate an exception.
> > Maybe you mean that Visual C++ generates an exception for null-pointer
> > accesses?
> >
> > > And if you continue your laughs, I can tell you that this is
> > > completely compliant.

> >
> > This means it would have to check every single pointer
> > access (and every division, if it also generates exceptions for
> > divide-by-zero), so in the context of the OP's question
> > "what overhead?", the answer would have to be "a lot".

>
> No - you are misunderstanding my post - especially the part you snipped
>
> I am saying that one legal behaviour of dereferencing a null pointer is to
> throw an exception. This is so because the behaviour in this case - and
> other cases of this nature - is unspecified: anything can happen.
>

Yes, we all know that. What has that got to do with whether it is
laughable to capture null pointer exceptions? So I snipped parts
related to that.
I repeat the assertion of Steven T. Hatton:

> > > > C++ programmers catching null pointer exceptions?
> > > > I'll let you know when I stop laughing.


I agree, you seem to disagree, why? (The fact that null pointer
exceptions exist does not imply that catching them is not laughable).
 
Reply With Quote
 
Peter Koch Larsen
Guest
Posts: n/a
 
      09-14-2004

"Old Wolf" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed) om...
> "Peter Koch Larsen" <(E-Mail Removed)> wrote:
> > "Old Wolf" <(E-Mail Removed)> skrev i en meddelelse:
> > > "Peter Koch Larsen" <(E-Mail Removed)> wrote:


[snip]
> > >
> > > This means it would have to check every single pointer
> > > access (and every division, if it also generates exceptions for
> > > divide-by-zero), so in the context of the OP's question
> > > "what overhead?", the answer would have to be "a lot".


Why the above statement if You do not believe that C++ should throw in case
of accessing a null pointer? That is how i took and - until i saw your "we
all know that" remark later.
Please note that i have not in any post (in this thread or elsewhere)
indicated that the throw was sensible.

> >
> > No - you are misunderstanding my post - especially the part you snipped


> >
> > I am saying that one legal behaviour of dereferencing a null pointer is

to
> > throw an exception. This is so because the behaviour in this case - and
> > other cases of this nature - is unspecified: anything can happen.
> >

> Yes, we all know that. What has that got to do with whether it is
> laughable to capture null pointer exceptions? So I snipped parts
> related to that.


It is not so laughable to catch these if they are thrown, is it? There are
situations where a catch (...) is justified and in these situations you
will - with a given configuration of some compilers - catch null pointer
exceptions and stuff like that.

> I repeat the assertion of Steven T. Hatton:
>
> > > > > C++ programmers catching null pointer exceptions?
> > > > > I'll let you know when I stop laughing.

>
> I agree, you seem to disagree, why? (The fact that null pointer
> exceptions exist does not imply that catching them is not laughable).


Well - let us just agree that our sense of humour differs, then

Peter


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why is there now execption for windows? trying to listen twice tothe same port News123 Python 4 03-20-2010 05:11 PM
security execption =?Utf-8?B?Q3NoYXJwR3V5?= ASP .Net 3 02-27-2006 11:14 AM
BGP Dampening - Attribute change penalty 500 Lee Cisco 2 02-21-2004 04:27 AM
Cancel "1-year" DSL contract with ISP without penalty - how to do it? L Mehl Computer Support 13 09-29-2003 11:52 PM
Is there Performance Penalty for multiple cross-assembly-calls? Peter Bär ASP .Net 2 07-18-2003 03:17 AM



Advertisments