We are building a high performance system and suddenly the cost of
using exception has been magnified.
What is the actual cost of having a frequent call inside a try-catch
block when the vast majority of times there will be no exception to
catch?
Many thanks. 5 7468
Tiglath wrote:
We are building a high performance system and suddenly the cost of
using exception has been magnified.
What is the actual cost of having a frequent call inside a try-catch
block when the vast majority of times there will be no exception to
catch?
I would think that someone experienced in building high performance
systems would know how to use a profiler...go figure.
It's implementation dependent. Could be nothing...could be an increase
in size....could be an increase in time...
You'll just have to use the scientific method.
Tiglath wrote:
We are building a high performance system and suddenly the cost of
using exception has been magnified.
What is the actual cost of having a frequent call inside a try-catch
block when the vast majority of times there will be no exception to
catch?
Many thanks.
Scott Meyers, "More Effective C++" has a good analysis on this, you
should read it.. but the gist is there will be an overhead associated
with exceptions, however if you do not incurr exceptions often (which
should be the case!), you probably will only take about a 5% hit in
performance... He cites studies in his book, I don't have it handy for
reference, sorry. But, thumb through it, its a pretty good book.
bjeremy wrote:
>
Scott Meyers, "More Effective C++" has a good analysis on this, you
should read it.. but the gist is there will be an overhead associated
with exceptions, however if you do not incurr exceptions often (which
should be the case!), you probably will only take about a 5% hit in
performance... He cites studies in his book, I don't have it handy for
reference, sorry. But, thumb through it, its a pretty good book.
Be sure to check out which compilers he's talking about. Compilers for
Windows used to use SEH for exceptions, and that, indeed, added runtime
overhead. Newer compilers are getting away from that, since it's not
really appropriate. And compilers for other platforms never did it.
Hypothetically, exceptions can be implemented with no runtime overhead
if you don't throw exceptions (except possibly for lost optimization
opportunities), and some compilers do just that.
As ever, the answer is, measure it.
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book)
Tiglath wrote:
We are building a high performance system and suddenly the cost of
using exception has been magnified.
What is the actual cost of having a frequent call inside a try-catch
block when the vast majority of times there will be no exception to
catch?
If you do not use exceptions as return value for one of correct state,
you will have no overhead if no error condition will occur.
This is one of example:
//code without exceptions
movl %esp, %ebp
pushl %ecx
subl $20, %esp
call _test
leave
ret
//the same code with exceptions
movl %esp, %ebp
pushl %ecx
subl $20, %esp
call _test
jmp L28
//catch
call ___cxa_begin_ca tch
call ___cxa_end_catc h
L28:
leave
ret
if no error condition will occur, program with exception will be longer
by one "jump" opcode. Of course, size of program with exception will be
greater, than without, but you can not make size smaller even with
manual control:
if(error_condit ion){print_erro r(); return;}
do_any();
will always ne longer then just
do_any();
Compiler even can tell CPU what kind of jump condition has more
priority for anticipatory memory access, if CPU supports it.
Tiglath skrev:
We are building a high performance system and suddenly the cost of
using exception has been magnified.
How? Did you measure the performance or is it just something you
believe is so?
>
What is the actual cost of having a frequent call inside a try-catch
block when the vast majority of times there will be no exception to
catch?
I don't believe there will be any overhead at all, but I'd question
your design anyway. Why do you need a try-catch around a function that
you believe is a bottleneck? In my experience, proper C++ code has very
few try-catch blocks, and they are never at such low a level.
/Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David MacQuigg |
last post by:
I'm concerned that with all the focus on obj$func binding, &closures,
and other not-so-pretty details of Prothon, that we are missing what
is really good - the simplification of classes. There are a number of
aspects to this simplification, but for me the unification of methods
and functions is the biggest benefit.
All methods look like functions (which students already understand).
Prototypes (classes) look like modules. This will...
|
by: Danny |
last post by:
Hi
Could somone please criticise the following program, it went together
far to easily (bearing in mind i am just getting into c++) **note the
tabs are not as they appear in my compliler**
Dan
/* This program will calculate the cost of running an electric appliance
|
by: Steven T. Hatton |
last post by:
I read Stroustrup's article of the day:
http://www.research.att.com/~bs/C++.html
Programming with Exceptions. InformIt.com. April 2001.
http://www.research.att.com/~bs/eh_brief.pdf
Some of these ideas are finally beginning to sink in. I believe I looked at
the same article a while back and decided I wasn't quite ready for it. If I
understood things correctly, there seems to be a slight problem with the
design of his exception safe...
|
by: gtux |
last post by:
Hi everybody:
I'm new in Javascript, I found some code and there is this:
var fruit =
{
'apple' : { 'weight' : 10, 'cost' : 9},
'peach' : { 'weight' : 19, 'cost' : 10}
}
|
by: BadPony |
last post by:
Anyone using Peoplesoft on a Federated UDB
(shared nothing)Environment on Open System Platforms?
Preferably AIX, but any war stories would be good.
TEA
EB-C
| |
by: Matt Alanzo |
last post by:
Our SOHO 2 person compay sells furniture (not programmers). In '98 we
paid $,$$$ for a VBA -Access '97 accounting application, including VBA
source code .... an huge investment for us then (and now!). The
application publisher went belly up years ago. Over time we've made a
number of VBA code changes (< 500 lines total). Now our CPA is urging
us to switch to Quickbooks Premier for Contractors at a cost of $,$$$
plus data entry. Argh, no...
|
by: Oliver Brausch |
last post by:
Hello,
have you ever heard about this MS-visual c compiler bug?
look at the small prog:
static int x=0;
int bit32() {
return ++x;
}
|
by: Salad |
last post by:
On the computer side of the businees there is me, the developer.
Another person's role is that of the idea man...the person that knows
the business and requirements and issues for the business. Together we
put together an application we both think is of value.
The app is written. Of course, the app is not finished. I suppose I
could work on this app for the rest of my days adding new features and
enhancing and adjusting as new...
|
by: walter.alex |
last post by:
November 16 2005 -- The recent launch of the new 5 year advertising
solution from MillionPixelClick.com means the pixel advertising craze
will continue unabated. Selling advertising space by the pixel the new
form of advertising is proving popular with both clients and providers
alike.
Designed to boost traffic, an image is placed on MillionPixelClick.com
with a link to your website. These pixels will be visible for at least
5 years....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |