caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Prevost <j.prevost@gmail.com>
To: caml-list@inria.fr
Cc: caml-list@inria.f
Subject: Re: [Caml-list] c is 4 times faster than ocaml?
Date: Wed, 4 Aug 2004 01:05:54 -0400	[thread overview]
Message-ID: <d849ad2a04080322052415a76c@mail.gmail.com> (raw)
In-Reply-To: <d849ad2a040803215967acd9ed@mail.gmail.com>

Oh, one last parting thought:

Part of why gcc is winning here is that it's actively working with the
fact that the loop variable, the index, and the value to be inserted
are the same value.  O'Caml is doing extra work because it's not
linking them up (it could at the very least avoid shifting a few
registers around and avoid an extra sarl instruction if it did spot
that.)

But this is the trouble with artificial benchmarks: no real code is
simply going to be copying the loop value into the array.  It's going
to be fetching the value from somewhere else, probably by doing
pointer arithmetic on the loop value and the source address, then it
will do pointer arithmetic on the loop value and the destination
address.  Then it will set the result.  A smart C coder will do the
arithmetic ahead of time, which means incrementing two values instead
of one each time through the loop, but wins overall.  Anyway, the
short is: artificial benchmarks are bad.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-08-04  5:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-04  2:39 effbiae
2004-08-04  4:59 ` John Prevost
2004-08-04  5:05   ` John Prevost [this message]
2004-08-04  5:24   ` effbiae
2004-08-04  7:28     ` John Prevost
2004-08-04  8:18       ` [Caml-list] " Jack Andrews
2004-08-04 10:06         ` Mikhail Fedotov
2004-08-04 10:25           ` [Caml-list] " Jack Andrews
2004-08-04 15:38             ` [Caml-list] custom mmap modeled on bigarray Jack Andrews
2004-08-10  5:06               ` Jack Andrews
2004-08-11 14:52                 ` Eric Stokes

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=d849ad2a04080322052415a76c@mail.gmail.com \
    --to=j.prevost@gmail.com \
    --cc=caml-list@inria.f \
    --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).