From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id EAA04881; Mon, 6 Aug 2001 04:40:32 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA04850 for ; Mon, 6 Aug 2001 04:40:31 +0200 (MET DST) Received: from javagroup.org (mail.bluetail.com [195.149.129.26]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f762eTH26428 for ; Mon, 6 Aug 2001 04:40:30 +0200 (MET DST) Received: (from luke@localhost) by javagroup.org (8.9.3/8.9.3) id EAA20426; Mon, 6 Aug 2001 04:40:23 +0200 X-Authentication-Warning: cockatoo.bluetail.com: luke set sender to luke@bluetail.com using -f To: caml-list@inria.fr Subject: [Caml-list] Newbie Ocaml performance questions From: Luke Gorrie X-Sincerity: 14% (approx.) Date: 06 Aug 2001 04:40:23 +0200 Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk G'day all, As a programming exercise, I've ported an Erlang program to Ocaml. It's the first caml code I've written, and the program is an optimiser from the ICFP contest. I was quite pleased to see that most of the program could be ported line-for-line straight into caml. Now I'm having a look at the performance, and surprised to see that the Caml (native) and Erlang ones run at about the same speed. I'm curious about why this is and whether there are some simple things that would make the Caml version a lot quicker without changing the basic style. The program is almost purely functional and spends its time doing list traversals - sometimes building things on the stack, sometimes in an accumulator - and pattern matching. So I have a few questions: - Is it reasonable to expect purely functional list-based code to run really fast (compared to bytecode interpreted systems like Erlang), or does one usually "go imperative" to get speed? - Is there some common listy/recursive style that is particularly slow - e.g. deep recursions building up a stack? - Is there an easy way to measure the number of milliseconds it takes to evaluate a certain expression? And some miscellaneous: - How do I print to stdout a text representation of an arbitrary object? (Like the way the shell prints results) - Can I increase the stack size (for native and bytecode)? It seems to blow out on me at a depth of about 70,000 in simple functions - I'd like to be able to get about 100x deeper. Thanks for any help! Ocaml is a fun language. P.S., it's certainly not impossible that I've done something stupid and ported it too naively, but it looks pretty straight forward. -- "It seems possible that some sufficiently inquiring mind (loony) could find meaning in this." -- Graham Gorrie ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr