From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id QAA20285 for caml-redistribution; Thu, 31 Oct 1996 16:27:40 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id PAA27682 for ; Wed, 30 Oct 1996 15:08:28 +0100 Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id PAA14070 for ; Wed, 30 Oct 1996 15:08:27 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id PAA23046 for ; Wed, 30 Oct 1996 15:08:27 +0100 (MET) Received: from daedalus.epcc.ed.ac.uk (root@[129.215.56.21]) by concorde.inria.fr (8.7.6/8.7.1) with SMTP id PAA14063 for ; Wed, 30 Oct 1996 15:08:20 +0100 (MET) Received: from tufa.epcc.ed.ac.uk (jserot@tufa.epcc.ed.ac.uk [129.215.56.4]) by daedalus.epcc.ed.ac.uk (8.6.13/8.6.12) with ESMTP id OAA00743; Wed, 30 Oct 1996 14:08:04 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 Cc: caml-list@margaux.inria.fr In-Reply-To: <199610301340.OAA26778@pauillac.inria.fr> from "Xavier Leroy" at Oct 30, 96 02:40:38 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > [... 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