Re: Q: float arrays

Jocelyn Serot (jserot@epcc.ed.ac.uk)
Wed, 30 Oct 1996 14:08:03 +0000 (GMT)

Message-Id: <29461.199610301408@tufa.epcc.ed.ac.uk>
Subject: Re: Q: float arrays
To: Xavier.Leroy@inria.fr (Xavier Leroy)
Date: Wed, 30 Oct 1996 14:08:03 +0000 (GMT)
From: Jocelyn Serot <jserot@epcc.ed.ac.uk>
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