From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A702FBB84 for ; Wed, 12 Jul 2006 02:48:54 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6C0msJV018759 for ; Wed, 12 Jul 2006 02:48:54 +0200 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 CAA21779 for ; Wed, 12 Jul 2006 02:48:53 +0200 (MET DST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6C0mpLm021272 for ; Wed, 12 Jul 2006 02:48:52 +0200 Received: from localhost (nat00-c2 [172.16.60.194]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id k6C0mipL028640; Wed, 12 Jul 2006 09:48:44 +0900 (JST) Date: Wed, 12 Jul 2006 09:51:24 +0900 (JST) Message-Id: <20060712.095124.108739217.garrigue@math.nagoya-u.ac.jp> To: colanderman@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Performance of immediate objects From: Jacques Garrigue In-Reply-To: <875c7e070607110710k2ca8d548i7f9d8e22d801df8e@mail.gmail.com> References: <875c7e070607110710k2ca8d548i7f9d8e22d801df8e@mail.gmail.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 44B446F6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44B446F3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; foo:01 val:01 foo:01 val:01 bytecode:01 speedup:01 caml-list:01 slower:01 jacques:01 jacques:01 int:01 int:01 native:02 objects:02 objects:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 From: "Chris King" > Is there a substantial difference to the way in which > > class foo (i:int) = object > val v = i > method bar = v > end > > let mk_foo i = new foo i > > and > > let mk_foo (i:int) = object > val v = i > method bar = v > end > > are compiled? I've run a couple tests with the above and immediate > objects seem to be about 15% slower than classes. Is this because a > new method table is created for the immediate object every time or is > that the case for classes also? Certainly not. It would not be a 15% slowdown, but rather 10000%. Initialization occurs only once, but one needs to check whether it was done every time an object is created. However, the 15% slowndown is for bytecode. For native code this is a 15% speedup. Guess which one we try to optimize. Jacques Garrigue