caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Ocaml sums the harmonic series -- four ways, four benchmarks: floating point performance
Date: Sun, 23 Jan 2005 03:27:13 +0100	[thread overview]
Message-ID: <20050123022713.GA4333@first.in-berlin.de> (raw)
In-Reply-To: <3D3A6BF5-657B-11D9-A551-000393A34E82@mit.edu>

On Thu, Jan 13, 2005 at 10:53:16AM -0500, Will M. Farr wrote:
[...]
> Here's the code for the fastest implementation:
> 
> let sum_harmonic4 n =
>   let sum = ref 1.0 in
>   let ifloat = ref 2.0 in
>     for i = 2 to n do
>       sum := !sum +. 1.0/.(!ifloat);
>       ifloat := !ifloat +. 1.0
>     done;
>     !sum;;
> 
> let _ =
>   let n = int_of_string (Sys.argv.(1)) in
>     Printf.printf "%g\n" (sum_harmonic4 n);;

I tried harmonic4 on Powerbook G4, 400 MHz and the
native-code needs  about 1 min 50s.

The Bytecode for harmonic4 runs in about 1min 53 s.

It seems that there is no real distinction between
bytecode and native code. At least on that system,
#or at least on that task.


I use Panther OS. It seems that it's more than twice as fast as your OS
(look at the processor frequency: 400 MHz on my PB G4, 800 MHz on yours...).

Which OS are you running? An older version of Mac-OS-X? Or Linux? (which one?)

Maybe you can speed-up your calculations a lot, when installing a different
operating system on your computer.

I didn't try the other implementations.
IMHO you can gain more performance easier, when
changing your OS. Easier than looking at some code optimizations...?!
                                   (which you nevertheless can do too)


Ciao,
   Oliver


  parent reply	other threads:[~2005-01-23  2:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-13 15:53 Will M. Farr
2005-01-13 17:29 ` [Caml-list] " John Prevost
2005-01-13 19:01   ` Will M. Farr
2005-01-13 20:24     ` John Prevost
2005-01-13 20:50       ` Erik de Castro Lopo
2005-01-13 21:32         ` Erik de Castro Lopo
2005-01-15 11:55 ` Xavier Leroy
2005-01-15 15:49   ` Michal Moskal
2005-01-15 17:01   ` [Caml-list] [FP performance] Ocaml sums the harmonic series Christophe TROESTLER
2005-01-15 17:13   ` [Caml-list] Ocaml sums the harmonic series -- four ways, four benchmarks: floating point performance Yaron Minsky
2005-01-23  2:27 ` Oliver Bandel [this message]
2005-01-23  6:07   ` Will M. Farr
2005-01-23 15:18     ` Oliver Bandel
2005-01-16  9:57 Philippe Lelédy

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=20050123022713.GA4333@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@yquem.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).