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.4 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR, SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 1B12FBC69 for ; Tue, 26 Jun 2007 15:35:07 +0200 (CEST) Received: from smtp.janestcapital.com (www.janestcapital.com [66.155.124.107]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5QDZ6kJ002239 for ; Tue, 26 Jun 2007 15:35:06 +0200 Received: from [172.25.131.105] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id A6190240; Tue, 26 Jun 2007 09:35:21 -0400 Message-ID: <46811608.5080707@gnu.org> Date: Tue, 26 Jun 2007 09:35:04 -0400 From: Sam Steingold User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: tmp123@menta.net Cc: caml-list@inria.fr Subject: Re: Execution time of class versus record References: <467E8A6E.9050700@menta.net> In-Reply-To: <467E8A6E.9050700@menta.net> X-Enigmail-Version: 0.95.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 4681160A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hash:01 ocamlopt:01 hash:01 computed:01 compile-time:01 gettimeofday:01 printf:01 printf:01 gettimeofday:01 wrote:01 unix:01 unix:01 slower:02 latter:03 latter:03 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 tmp123@menta.net wrote: > Hello, > > I've tried to implement two equivalent small programs, the one using > class, the other one using records. The resulting execution times says > that class are 7-8 times slower than record (compiled with ocamlopt in a > Intel machine). As other have explained, classes use hash table lookup per slot access, while records access fields by offsets computed at compile-time. > Please, knows someone what I'm doing wrong? > let t0 = Unix.gettimeofday () in > Printf.printf "elapsed = %f\n" (Unix.gettimeofday() -. t0) Unix.gettimeofday is "wall clock". Unix.times is "CPU time". use the latter to time your programs because the former depends on the machine load at the time of the test while the latter does not. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGgRYIPp1Qsf2qnMcRAiC5AJkBPG/XrrH3mSZuP+YFTtLk+xF4YACdGmdF zijSDKnxkm6BIpXDQ+DkLwE= =lchS -----END PGP SIGNATURE-----