2007/2/11, fabrice.marchant < fabrice.marchant%40orange.fr">fabrice.marchant
orange.fr>:
[...]
> let b = new board width height in
> let d = new display width height box_n in
[...]
>
> However, ( after restricting OCaml pgm to (0, 0) start square - to
> compare same jobs ), the C program appears to be about 10 times speeder.
> I thought C/OCaml speed ratio was smaller, say about 2 or 3. But maybe
> something goes wrong with my program.
You fell in the object trap : objects are slower in ocaml than the
rest of the language, and not so useful. rewrite your code in plain
caml (with object), compile it ocamlopt, and you will have more
similar result, with one catch : ocaml array bound are by default
checked at each access, will C array are not, then f you want speed
over safety, you can compile with the -unsafe option of the compiler.
.