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 NAA18229; Mon, 17 Mar 2003 13:28:46 +0100 (MET) 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 NAA17983 for ; Mon, 17 Mar 2003 13:28:44 +0100 (MET) Received: from lachesis.inria.fr (lachesis.inria.fr [128.93.52.5]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2HCSBf25383; Mon, 17 Mar 2003 13:28:11 +0100 (MET) Received: (from lefessan@localhost) by lachesis.inria.fr (8.12.5/8.12.5/Submit) id h2HBd3e0009385; Mon, 17 Mar 2003 12:39:03 +0100 From: Fabrice Le Fessant MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15989.46038.984076.710373@lachesis.inria.fr> Date: Mon, 17 Mar 2003 12:39:02 +0100 To: "Daniel M. Albro" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Loop times References: <1047592439.1866.10.camel@giynz> X-Mailer: VM 7.07 under Emacs 21.2.1 Reply-To: fabrice@lefessant.net X-Spam: no; 0.00; caml-list:01 exception:02 allocate:03 exn:03 sys:03 let:04 ary:04 fabrice:04 raise:05 fessant:06 loop:06 fun:08 break:11 code:15 but:16 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > OK, I just did a test of the three methods. Here's the code: > > Exception Version: > ------------------------------------------------- > exception Break > > let _ = > let ary = [|1;2;3;4;5;6;7;8;9;10;11;12|] in > for i = 1 to 1_000_000_000 do > try > for j = 1 to 10 do > if ary.(j) = 5 then > raise Break > done > with Break -> () > done > > real 0m30.569s > user 0m30.250s > sys 0m0.140s > ------------------------------------------------------ For the fun, could you try this one ? It does not allocate the exception in the loop but outside. ------------------------------------------------- exception Break let _ = let ary = [|1;2;3;4;5;6;7;8;9;10;11;12|] in let exn = Break in for i = 1 to 1_000_000_000 do try for j = 1 to 10 do if ary.(j) = 5 then raise exn done with Break -> () done ------------------------------------------------------ - Fabrice ------------------- 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