Re: How expensive are exceptions?
On 22 Jun., 17:56, "Sergey P. Derevyago" <non-exist...@iobox.com>
wrote:
David Abrahams wrote:
I've tried to be as specific as possible, but it's probably still
possible to do something I haven't considered that makes the test
unfair. If you can understand the spirit of what I'm trying to
express above, then I'm not worried about that.
I'm afraid I can.
The spirit is to transform the code in some tricky ways just to
prove that
EH imposes no runtime overhead.
In principle, the error handling can be implemented in the following
way:
[snipped code fearing rejection because of overquoting]
Is it "fair"?
I would say "sort of" fair. What I do not understand is the need for
the exception-based code to return a value. A fair comparison would be
to have g1, gH and h have a void signature. An even more realistic
example might be to have the functions "return" something - e.g.
returning an int in the exceptionbased code and having an int&
parameter in the exception-free path. This more realistic example will
most likely favour exceptions.
(I have not tested the code as the only compilers available to me use
the "structured EH" principle devised by Microsoft. I believe we all
agree that there will be an overhead in this case).
/Peter
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]