| | |
Performance Issue
![]() |
•
•
Join Date: May 2005
Posts: 48
Reputation:
Solved Threads: 3
Hi Friends,
Can any of you pls tell me (in detail) which of the following options will be faster?
Option 1:
Option 2:
Thanx,
Amit
Can any of you pls tell me (in detail) which of the following options will be faster?
Option 1:
C Syntax (Toggle Plain Text)
int fun() { if( !cm_aObject ) return -1; return cm_aObject->getNum(); }
Option 2:
C Syntax (Toggle Plain Text)
int fun() { try{ return cm_aObject->getNum(); }catch(...){ return -1; } }
Thanx,
Amit
That doesn't mean you should avoid exception handling; in fact the performance loss is so minimal, it's hardly worth taking that into account when trying to decide when and where to use exception handling. Option 2 is by far the most robust.
"Technological progress is like an axe in the hands of a pathological criminal."
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
•
•
•
•
in fact the performance loss is so minimal, it's hardly worth taking that into account when trying to decide when and where to use exception handling.
a. you do not have to pay a high performance penalty in the event of there being no error
b. if there is an error, you are willing to spend time recovering from it.
c. exceptions, as the name suggests, are used to indicate exceptional conditions that do not occur in the normal course of events.
Ancient Dragon's statement is accurate; the easiest way to check it out is
a. generate the assembly code for both versions and have a look at it.
b. write a test driver and time the performance on your implementation.
![]() |
Similar Threads
- recommended reading on Novell? (Novell)
- urgently need help regarding performance issue of WinServer 2003 & dual core procesor (Windows NT / 2000 / XP)
- regarding Win Server 2003 & dual core processors performance issue (Windows NT / 2000 / XP)
- Performance issue encountered need another approach (Oracle)
- Self Hosting (Networking Hardware Configuration)
- embPerl or PHP (Perl)
- MySQL vs. PostgreSQL (MySQL)
Other Threads in the C Forum
- Previous Thread: C array I/O
- Next Thread: Np-complete array generator
| Thread Tools | Search this Thread |
* ansi api array arrays binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() database directory dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o inches include infiniteloop input intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft mysql oddnumber open opendocumentformat openwebfoundation pdf pointer posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi






