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 IAA15132; Wed, 19 May 2004 08:22:15 +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 IAA15073 for ; Wed, 19 May 2004 08:22:14 +0200 (MET DST) Received: from fed1rmmtao01.cox.net (fed1rmmtao01.cox.net [68.230.241.38]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4J6MBEV020175 for ; Wed, 19 May 2004 08:22:12 +0200 Received: from server.vns.oc.ca.us ([68.5.38.56]) by fed1rmmtao01.cox.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20040519062205.RPWI21007.fed1rmmtao01.cox.net@server.vns.oc.ca.us>; Wed, 19 May 2004 02:22:05 -0400 Received: from server.vns.oc.ca.us (a1deded7977b45d3cb7641949dfc6e76@localhost.vns.oc.ca.us [127.0.0.1]) by server.vns.oc.ca.us (8.12.9p2/8.12.6) with ESMTP id i4J6M27k065126; Tue, 18 May 2004 23:22:03 -0700 (PDT) (envelope-from vns@server.vns.oc.ca.us) Received: (from vsilyaev@localhost) by server.vns.oc.ca.us (8.12.9p2/8.12.6/Submit) id i4J6LvLM065125; Tue, 18 May 2004 23:21:57 -0700 (PDT) Date: Tue, 18 May 2004 23:21:57 -0700 From: "Vladimir N. Silyaev" To: caml-list@inria.fr Cc: Kenneth Knowles Subject: [Caml-list] Lazy vs closure Message-ID: <20040519062157.GA65076@server.vns.oc.ca.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7" Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Miltered: at nez-perce with ID 40AAFD13.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; slower:01 coredumps:01 uncommenting:01 coredump:01 stepped:01 bug:01 uncomment:01 endline:01 inconsistent:01 compilers:01 byte:01 closure:01 closure:01 lazy:02 lazy:02 X-Attachments: name="lazy.ml" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline After reading list and seeing statement that lazy/Lazy.force is faster then closure/apply, I've decided to run microbenchmark with both. Results are rather confusing: Byte code - Lazy is three times slower than closure Native code (x86) - it's either coredumps or leaks memory Code attached as <>. With it's current form native code leaks memory, by uncommenting first two lines it would coredump. Also both compilers tends to generate rather strange error. =-=-=-=-=-= The files lazy.cmi and lazy.cmi make inconsistent assumptions over interface Lazy =-=-=-=-=-= This error fixable by removing lazy.cmi from a disk. Have I stepped on some known bug/feature? Vladimir --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lazy.ml" (* Uncomment me let l = lazy (1+1) let _ = Lazy.force l *) let fixit = ref 0 let test_lazy n = let l = lazy (n+1) in fixit := Lazy.force l let test_closure n = let c = (fun _ -> n+1) in fixit := c () let test n test = let start = Sys.time () in for i=0 to n do test i done; (Sys.time ()) -. start let result = List.map (test 1000000) [test_lazy; test_closure] let _ = List.iter print_endline (List.map string_of_float result) --fdj2RfSjLxBAspz7-- ------------------- 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