Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: The performance cost of using exceptions?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: The performance cost of using exceptions?
> Are programs written to make heavy use of exceptions going to be markedly
> slower than programs written more traditionally with loops/ifs, etc?

That depends on how you use them. It is well possible to do this in such a
way that you actually increase performance.

For example, when inserting elements into a binary tree, the naive version
always copies the "spine" of the tree, even if the element is already a
member.

But if you use exceptions, you can "jump back" and can thus prevent the
spine from being copied. This normally reduces the load of the garbage
collector and yields some percent more performance.

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl