Version française
Home     About     Download     Resources     Contact us    
Browse thread
Question on writing efficient Ocaml.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Manfred Lotz <manfred.lotz@y...>
Subject: Re: Question on writing efficient Ocaml.
On Thu, 28 Dec 2006 11:42:04 +0000
"Ian Oversby" <oversby@hotmail.com> wrote:

> Hi,
> 
> Apologies if this is the wrong forum in which to ask this question.
> Is there anywhere else more
> suitable?
> 
> I've written some Ocaml code to solve the problem of placing 8 queens
> on a board so that none of them attack each-other.  I've also written
> a C++ equivalent which is running much more quickly than the Ocaml.
> I assume I've made some basic errors with the Ocaml - does anyone
> have any suggestions as to what?
> 
> The code is available here:
> 
> http://curiousprogrammer.wordpress.com/2006/12/22/speed-comparison-plt-scheme-ocaml-and-c/
> 
> I compiled the Ocaml with the following command:
> 
> ocamlopt -noassert -unsafe -ccopt -O3 -ccopt -fomit-frame-pointer
> q.ml -o q.exe
> 

I personally don't believe that it is a good idea to use options
like: -noassert -unsafe -ccopt -O3 -ccopt -fomit-frame-pointer
I regard bounds checkings and assertions as good features of Ocaml and
not as something to avoid in order to achieve good performances. 


It is more important to have a stable binary. If you want to speed up
it is a matter of using a good algorithm.


-- 
Manfred