From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA30251; Sat, 28 Jun 2003 03:16:33 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA30168 for ; Sat, 28 Jun 2003 03:16:31 +0200 (MET DST) Received: from woodstock.1969.ws (64-215-156-42.eosinc.net [64.215.156.42]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id h5S1GUf16024 for ; Sat, 28 Jun 2003 03:16:30 +0200 (MET DST) Received: (qmail 32183 invoked from network); 28 Jun 2003 00:53:22 -0000 Received: from karl.1969.ws (HELO 1969.ws) (10.3.2.15) by woodstock.1969.ws with SMTP; 28 Jun 2003 00:53:22 -0000 Message-ID: <3EFCEC9F.3070704@1969.ws> Date: Fri, 27 Jun 2003 18:17:19 -0700 From: Karl Zilles Organization: 1969 Communications, Inc. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Zed Sereg CC: caml-list@inria.fr Subject: Re: [Caml-list] Operation complexity References: <001001c33ccc$5e878300$a806df80@chrisgd> <20030628.030009.92588696.yoriyuki@mbg.sphere.ne.jp> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; caml-list:01 zed:99 val:01 arrays:01 believing:98 complexity:02 string:03 wrote:03 fire:96 let:04 vector:04 profiler:04 array:04 slow:05 separately:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Zed Sereg wrote: > Hello World, I have a obfuscating question, for whih I can found no answer. > > I have to handle huge string arrays in a kind of database parsing. > At the end, i have a code of the shape : > let request_word s = ... > val request_word : string -> string array list > > let associate v = > let n = Array.length v in > let v' = array.make n (request_word v.(0)) in > for i = 1 to n-1 ledo > v'.(i) <- (request_word v.(i)); > done; > v' > ;; > > val associate : string array -> string array list array = Hi Zed, Have you looked at Array.map? let associate = Array.map request_word;; > > Yeah, it 's obfuscating, but I had no time to find another solution.And > this is awfully slow... (In order to know, the computating time of each > request separately is around 2 secs. I waited 5 minutes for a call of > associate with a 3 elements vector.) I have trouble believing that associate is your problem. Time to fire up the profiler to find out where that time is coming from? > > I would like to know if there is a way to do the same thing, without > replacing a value in v' at each iteration. Would it really be better to > switch the structure from an array to a temporary list, and after, > copying the list into an array with Array.of_list. Your code looks ok to me. I think your problem is elsewhere. Karl ------------------- 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