caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Luke Gorrie <luke@bluetail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Newbie Ocaml performance questions
Date: 06 Aug 2001 04:40:23 +0200	[thread overview]
Message-ID: <lhitg1lxm0.fsf@cockatoo.bluetail.com> (raw)

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


             reply	other threads:[~2001-08-06  2:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-06  2:40 Luke Gorrie [this message]
2001-08-06  3:04 ` Pixel

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=lhitg1lxm0.fsf@cockatoo.bluetail.com \
    --to=luke@bluetail.com \
    --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;
as well as URLs for NNTP newsgroup(s).