From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 39E3ABC6C for ; Fri, 18 Jan 2008 08:39:44 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAJ7mj0dIDsqzh2dsb2JhbACQFgEBAQgEBAkKEZUlh3M X-IronPort-AV: E=Sophos;i="4.25,214,1199660400"; d="scan'208";a="21463522" Received: from ro-out-1112.google.com ([72.14.202.179]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Jan 2008 08:39:29 +0100 Received: by ro-out-1112.google.com with SMTP id o32so838716rog.11 for ; Thu, 17 Jan 2008 23:39:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=jRtQzU6SSjjPDYACebYp84bUZkwqqGRr/x7ke72C0mA=; b=CqAYWHVutvXXIp/AC1UFNo0W9GJSnci44ud+1C1X7pSM40IDQJTCWjHQ4++MO8qcxpA02KRrUr0zsx0hW0K4UAbjlmewla2YPVh7mLZYnPdRs2wqEwJfcXIMEcB3jAZfNyktc9eMFVTNFKdRD8YdK9qN0Jko+HeXX4i8YQPX+5w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lI2D0kUZhT/3vmQCA50yj0I9nZs+vOh6L8zr7LStMSQClkZhApTMbIIMGolU1vwt1AP04yRGBWov2laTP+Mmd0uXUsx8o7MK8QW9506poDe9Jdo45ABFoS8WAFPvVdrHF2AR7oAyVGb9orefQaOnCf92mUmZWSTQsKTuJzHFBwA= Received: by 10.142.232.20 with SMTP id e20mr1765963wfh.198.1200641967150; Thu, 17 Jan 2008 23:39:27 -0800 (PST) Received: by 10.142.115.3 with HTTP; Thu, 17 Jan 2008 23:39:27 -0800 (PST) Message-ID: <9d3ec8300801172339j38bf734dm5b84f951a4342188@mail.gmail.com> Date: Fri, 18 Jan 2008 07:39:27 +0000 From: "Till Varoquaux" To: "Jacques Garrigue" Subject: Re: [Caml-list] Strange performances Cc: benjamin.canou@gmail.com, caml-list@yquem.inria.fr In-Reply-To: <20080118.111503.185813743.garrigue@math.nagoya-u.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1200619933.6383.47.camel@benjamin-laptop> <20080118.111503.185813743.garrigue@math.nagoya-u.ac.jp> X-Spam: no; 0.00; segfaults:01 segfaults:01 cheers:01 bytecode:01 bug:01 failwith:01 endline:01 pred:01 ocamlopt:01 ocamlc:01 ocaml:01 -version:01 toplevel:01 beginner's:01 ocaml:01 On Jan 18, 2008 2:15 AM, Jacques Garrigue wrote: ... > By the way, on my machine your version doesn't even work in native > code, I only get segfaults. This is allowed behaviour for > out-of-bounds access. Could you please clarify? This seems a little scary to me, I thought segfaults where acceptable only when you used unsafe features (or ran out of stack). Cheers, Till > > Jacques Garrigue > > From: Benjamin Canou > > > Hi, > > > > The code following my message is way faster in bytecode than in native > > code. Is there a good reason for that or is it a bug ? > > Note : It is a (way too, I know) naive implementation of the well known > > string suite 1, 11, 21, 1211, 111221, ... > > > > Benjamin Canou. > > > > === code === > > > > let list_of_string s = > > let rec list_of_string s i = > > try s.[i] :: list_of_string s (succ i) > > with _ -> [] > > in list_of_string s 0 > > > > let rec trans = function > > | '1' :: '1' :: '1' :: tl -> "31" ^ trans tl > > | '1' :: '1' :: tl -> "21" ^ trans tl > > | '1' :: tl -> "11" ^ trans tl > > | '2' :: '2' :: '2' :: tl -> "32" ^ trans tl > > | '2' :: '2' :: tl -> "22" ^ trans tl > > | '2' :: tl -> "12" ^ trans tl > > | '3' :: '3' :: '3' :: tl -> "33" ^ trans tl > > | '3' :: '3' :: tl -> "23" ^ trans tl > > | '3' :: tl -> "13" ^ trans tl > > | [] -> "" > > | _ -> failwith "bad input" > > > > let rec print n s = > > print_endline s ; > > if n > 0 then print (pred n) (trans (list_of_string s)) > > > > let _ = print 30 "1" > > > > === perfs === > > > > benjamin@benjamin-laptop:~/Work/Stuff$ ocamlopt 123.ml -o 123 > > benjamin@benjamin-laptop:~/Work/Stuff$ time ./123 > > [...] > > real 0m5.245s > > user 0m4.944s > > sys 0m0.016s > > benjamin@benjamin-laptop:~/Work/Stuff$ ocamlc 123.ml -o 123 > > benjamin@benjamin-laptop:~/Work/Stuff$ time ./123 > > [...] > > real 0m1.097s > > user 0m0.840s > > sys 0m0.008s > > benjamin@benjamin-laptop:~/Work/Stuff$ ocaml -version > > The Objective Caml toplevel, version 3.09.2 > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://till-varoquaux.blogspot.com/