Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2000-05-15 (20:10)
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

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,,