473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

What does it cost to try?

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
Jul 22 '05 #1
2 1411
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:2v********************@speakeasy.net...
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_u...g-Control.html)
.. You might get better answers in a newsgroup that discusses your
implementation.

--
David Hilsee
Jul 22 '05 #2
"David Hilsee" <da*************@yahoo.com> wrote in message
news:Cs********************@comcast.com...
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:2v********************@speakeasy.net...
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_u...g-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
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mark | r | last post by:
is there an industry standard method of costing out a project the problem i have is that when talking to a developer they say "i dont know how long it will take" which just isnt acceptable #...
8
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** ...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
28
by: joe | last post by:
I have a simple .NET application with two or three listViews which are filled with icons and when the user click on the proper item, they display the related images. I use "image = null ; " for all...
4
by: David Link | last post by:
Hi, Why does adding SUM and GROUP BY destroy performance? details follow. Thanks, David Link s1.sql: SELECT t.tid, t.title, COALESCE(s0c100r100.units, 0) as w0c100r100units,
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
6
by: blue875 | last post by:
A tale of two queries: One query looks like this, and runs fine. We'll call this the "Customer1 query": SELECT Customer1 overall.*, IIf(IsNull(.),0,1) AS IsField, IIf(IsNull(.),0,1) AS...
15
by: ingejg | last post by:
I am starting to study internet synchronization, and my head is still spinning since internet is not my forte, however my boss is breathing down my neck at the moment. Our company has only one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.