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 LAA08409; Tue, 20 May 2003 11:55:41 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA08399 for ; Tue, 20 May 2003 11:55:40 +0200 (MET DST) Received: from teutates.kfunigraz.ac.at (TEUTATES.kfunigraz.ac.at [143.50.129.26]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h4K9tdH22645 for ; Tue, 20 May 2003 11:55:39 +0200 (MET DST) Received: from localhost (localhost.localdomain [127.0.0.1]) by teutates.kfunigraz.ac.at (Postfix) with ESMTP id BC5F53D222F for ; Tue, 20 May 2003 11:55:27 +0200 (CEST) Received: from teutates.kfunigraz.ac.at ([127.0.0.1]) by localhost (teutates.kfunigraz.ac.at [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 27950-10 for ; Tue, 20 May 2003 11:55:20 +0200 (CEST) Received: from stud.uni-graz.at (IGAM08AV.kfunigraz.ac.at [143.50.39.35]) by teutates.kfunigraz.ac.at (Postfix) with ESMTP id DEB373D2233 for ; Tue, 20 May 2003 11:54:44 +0200 (CEST) Message-ID: <3EC9EA84.3070404@stud.uni-graz.at> Date: Tue, 20 May 2003 10:42:44 +0200 From: Siegfried Gonzi Organization: Universitaet Graz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: "'caml-list@inria.fr'" Subject: [Caml-list] Reading a file References: <4.3.2.7.2.20030517225010.04b748a0@localhost> <4.3.2.7.2.20030519120753.04545700@localhost> <200305201007.17990.wolfgang.mueller2@uni-bayreuth.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at stud.uni-graz.at X-Spam: no; 0.00; siegfried:01 gonzi:01 stud:99 bigloo:01 secondes:99 ocaml:01 exists:01 constructs:02 overhead:03 string:03 converts:03 slow:05 red:94 pattern:06 construct:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi: Is there a better way in Ocaml to read a file line by line than via the read_line function? I use read_line on a file, perform some tasks on this line and store the results in a list and after having red the file I use List.rev. The problem actually is on big files the function is awfully slow. As similar Clean function takes 15 seconds, my Bigloo program takes 25 second and my C++ programs (via templates) takes 25 secondes but my Ocaml program takes 8 minutes. I am not sure how quick List.rev actually is? In Bigloo reversing a list has more or less no overhead. My Bigloo function is similar to my OCaml function. Could it be that OCaml is that slow because I use "try and with" constructs in order to check for the end of a file? Why my Clean function is that fast is incomprehensible for me. Does one know whether there exists a function in OCaml which converts a String to a character-list? I use this construct in Clean then in order to extract floating point numbers from that character list: ['1','.','2',...] and store this floating point numbers via pattern matching in my result-list. S. Gonzi > > ------------------- 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