Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Helmut Brandl <helmut.brandl@gmx.net>
To: caml-list@inria.fr
Subject: [Caml-list] Performance penalty of exception handling
Date: Wed, 16 Sep 2015 14:08:06 -0500	[thread overview]
Message-ID: <55F9BE16.1020502@gmx.net> (raw)

Hi all,

I use exeption handling quite frequently even in inner loops. A common 
pattern:

     let some_function ... =
             ...
            if cannot_compute then raise Not_found else value

     try
         let value = some_function ... in
         ...
     with Not_found ->
        handle_exception

I use this pattern even if the direct caller of "some_function" handles 
the exception. In many cases I could design "some_function" in a way 
that it returns an optional value and check the optional value in the 
caller. Is this significantly (at least 10%) faster? If not, I would 
stay with my present design. However I am pressed for performance in the 
inner loops (I am only interested in compilation to native).

Is there any information available on the preformance penalty of 
exception handling? Any hints? Thanks in advance.

Regards
Helmut

             reply	other threads:[~2015-09-16 19:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 19:08 Helmut Brandl [this message]
2015-09-16 19:15 ` John Whitington
     [not found]   ` <CAKR7PS9iibAcWVMbjahdkVn6KBXUZa0U88KwZEkqc-LzfaBUKg@mail.gmail.com>
2015-09-16 19:51     ` Milan Stanojević
2015-09-16 20:00 ` David Rajchenbach-Teller
2015-09-16 19:26 "Mark Adams"

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55F9BE16.1020502@gmx.net \
    --to=helmut.brandl@gmx.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox