Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jocelyn Serot <jserot@epcc.ed.ac.uk>
To: Xavier.Leroy@inria.fr (Xavier Leroy)
Cc: caml-list@margaux.inria.fr
Subject: Re: Q: float arrays
Date: Wed, 30 Oct 1996 14:08:03 +0000 (GMT)	[thread overview]
Message-ID: <29461.199610301408@tufa.epcc.ed.ac.uk> (raw)
In-Reply-To: <199610301340.OAA26778@pauillac.inria.fr> from "Xavier Leroy" at Oct 30, 96 02:40:38 pm


> [... lots of interesting comments deleted ...]
>
> If you inline the "*." operation in map2, all boxing will be
> eliminated (and all dynamic tests as well, since the function is now
> monomorphic), and you'll get much better performance than what can be
> obtained with an array of pairs:
> 
>  let product f a a' =
>    let l = length a in
>    if ( length a' != l ) then invalid_arg "product" else
>    if l = 0 then [||] else begin
>      let r = create l (f(unsafe_get a 0)(unsafe_get a' 0)) in
>      for i = 1 to l - 1 do
>        unsafe_set r i (unsafe_get a i *. unsafe_get a' i)
>      done;
>      r
>    end

Ok, i tried this. Here are the results:

jserot@tufa$ omain
 Number of samples is 1683
 Each sample counts as 0.02 seconds.

 %       self     self&            self    total
 time    seconds  children  calls  ms/call ms/call name
-------------------------------------------------------
63.10   18.527   18.527       11   1.684   1.684   map2
36.24   10.641   10.641       11   0.967   0.967   map_pairs
 0.59    0.174    0.174       11   0.016   0.016   product

Self-demonstrative. 

Thanks for your help,

	Jocelyn
-- 
E-mail: jserot@epcc.ed.ac.uk (->Nov 29 1996) ................................
S-mail: LASMEA - URA 1793 CNRS, Universite Blaise Pascal, 63177 Aubiere cedex
Tel: (33) 73.40.73.30 - Fax: (33) 73.40.72.62 ...............................
.... http://wwwlasmea.univ-bpclermont.fr/Personnel/Jocelyn.Serot/Welcome.html





  reply	other threads:[~1996-10-31 15:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-29 11:12 Jocelyn Serot
1996-10-30 13:40 ` Xavier Leroy
1996-10-30 14:08   ` Jocelyn Serot [this message]
1996-10-30 14:52   ` Thorsten Ohl
1996-10-31 15:26     ` Xavier Leroy
1996-11-05 16:56     ` Controlling inlining [was Re: Q: float arrays] rowan+

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=29461.199610301408@tufa.epcc.ed.ac.uk \
    --to=jserot@epcc.ed.ac.uk \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@margaux.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