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.1 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 3273DBC69 for ; Wed, 3 Oct 2007 16:34:54 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGtDA0fAXQImh2dsb2JhbACCPTSLRwEBAQgKJw X-IronPort-AV: E=Sophos;i="4.21,225,1188770400"; d="scan'208";a="3703426" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 03 Oct 2007 16:34:53 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l93EYkH1021196 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 3 Oct 2007 16:34:53 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAIxFA0fRVZK3kmdsb2JhbACCPTSLRwEBAQEHAgYRFg X-IronPort-AV: E=Sophos;i="4.21,225,1188770400"; d="scan'208";a="2079153" Received: from wa-out-1112.google.com ([209.85.146.183]) by mail1-smtp-roc.national.inria.fr with ESMTP; 03 Oct 2007 16:34:54 +0200 Received: by wa-out-1112.google.com with SMTP id m34so6262345wag for ; Wed, 03 Oct 2007 07:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=TJpPCTFJTZZ1VZoZx76mb4qmyl5H41kLitfyHSEnFJM=; b=JcPPYc37qYu7KUjcV2QmDh9R5mcZRy/j5O80dJkToufKrCCog82JtYkUaUMSiTbbD9Q/s1i3kc5WDzxDNEotMfT++DiroJ3R5a4c2N9awV96afePJv0q3UxBP2+qgB+bWbDnzKL/5IMJe/cP+a5B4PjgGnOcc8RtxwwDPtq78aM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=ILscztkB7IEFWc3kcIE8jwxyXqvsHjRaap7W6RpjhE7wo5e3SrXB6U7TdUbN0Z+XesenMN/PVeCOPvzr0N7p5UhFqas2lTEpkobVbGHJfc29N69uZz1iyZpDfsltHCR4X+OuTXnlXrhX34NjFJSSIaXQ8dHQeT/lFg2x/e3xuMI= Received: by 10.114.200.2 with SMTP id x2mr2999095waf.1191422091842; Wed, 03 Oct 2007 07:34:51 -0700 (PDT) Received: by 10.114.25.8 with HTTP; Wed, 3 Oct 2007 07:34:51 -0700 (PDT) Message-ID: Date: Wed, 3 Oct 2007 16:34:51 +0200 From: kirillkh To: "Daniel de Rauglaudre" Subject: Re: [Caml-list] Re: Locally-polymorphic exceptions [was: folding over a file] Cc: caml-list@inria.fr In-Reply-To: <20071003123201.GA3833@yquem.inria.fr> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_23757_18299892.1191422091835" References: <20071003083529.40DA2A99F@Adric.metnet.fnmoc.navy.mil> <20071003114832.GB23824@yquem.inria.fr> <20071003123201.GA3833@yquem.inria.fr> X-Miltered: at discorde with ID 4703A886.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; rauglaudre:01 rauglaudre:01 0200,:01 variants:01 ocamlopt:01 ocaml:01 printf:01 printf:01 variants:01 readline:01 readline:01 ocaml:01 0200,:01 ocamlopt:01 W6:98 ------=_Part_23757_18299892.1191422091835 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/10/3, Daniel de Rauglaudre : > > Hi, > > On Wed, Oct 03, 2007 at 02:19:56PM +0200, kirillkh wrote: > > > But then someone suggested using a second exception instead, which > > is better performance-wise [...] > > Is that been checked ? And the two implementations tested ? What are the > results, in time ? > Tested from the top-level on a text file with 11mln lines: variants: 8.081 8.021 8.072 8.052 8.011 => avg=8.0474 exceptions: 7.801 7.902 7.822 7.901 7.832 => avg=7.8512 ----------------------------- total: exceptions are 2.44% faster I'm having troubles with ocamlopt (windows machine), can anyone do a similar test with it? Here's the code used (it's the pre-combinator version of line counter): exceptions (lcex.ml): exception Done of int;; let line_count filename = let file = open_in filename in let rec loop count = let _ = try input_line file with End_of_file -> raise (Done count) in loop (count + 1) in try loop 0 with Done x -> x ;; let start_time = Sys.time() in let count = line_count "c:/kirill/ocaml/test3.txt" in let diff = Sys.time() -. start_time in Printf.printf "count: %d, time: %f" count diff;; variants(lcvar.ml): let readline f = try Some (input_line f) with End_of_file -> None;; let line_count filename = let f = open_in filename in let rec loop count = match (readline f) with | Some(_) -> loop (count+1) | None -> count in loop 0;; let start_time = Sys.time() in let count = line_count "c:/kirill/ocaml/test3.txt" in let diff = Sys.time() -. start_time in Printf.printf "count: %d, time: %f" count diff;; -Kirill ------=_Part_23757_18299892.1191422091835 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/10/3, Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>:
Hi,

On Wed, Oct 03, 2007 at 02:19:56PM +0200, kirillkh wrote:

> But then someone suggested using a second exception instead, which
> is better performance-wise [...]

Is that been checked ? And the two implementations tested ? What are the
results, in time ?

Tested from the top-level on a text file with 11mln lines:
variants:
8.081  8.021  8.072  8.052  8.011  =>  avg=8.0474
exceptions:
7.801  7.902  7.822  7.901  7.832  =>  avg=7.8512
-----------------------------
total: exceptions are 2.44% faster

I'm having troubles with ocamlopt (windows machine), can anyone do a similar test with it? Here's the code used (it's the pre-combinator version of line counter):

exceptions (lcex.ml):
exception Done of int;;

let line_count filename =
 let file = open_in filename in
 let rec loop count =
   let _ =
     try
       input_line file
     with End_of_file -> raise (Done count)
   in
     loop (count + 1)
 in
   try loop 0 with Done x -> x
;;

let start_time = Sys.time() in
let count = line_count "c:/kirill/ocaml/test3.txt" in
let diff = Sys.time() -. start_time in
    Printf.printf "count: %d,  time: %f" count diff;;

variants(lcvar.ml):
let readline f =
  try Some (input_line f)
  with End_of_file -> None;;

let line_count filename =
  let f = open_in filename in
  let rec loop count =
    match (readline f) with
      | Some(_) -> loop (count+1)
      | None -> count in
  loop 0;;

let start_time = Sys.time() in
let count = line_count "c:/kirill/ocaml/test3.txt" in
let diff = Sys.time() -. start_time in
    Printf.printf "count: %d,  time: %f" count diff;;


-Kirill
------=_Part_23757_18299892.1191422091835--