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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 01A71BBAF for ; Mon, 23 Aug 2010 14:07:00 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYBAEMBckzBvsFKl2dsb2JhbACTJY0gAQEBAQEIFQczuEuFNwSJdg X-IronPort-AV: E=Sophos;i="4.56,257,1280700000"; d="scan'208";a="55912846" Received: from dnsp.umh.ac.be (HELO hermes1.umh.ac.be) ([193.190.193.74]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Aug 2010 14:07:00 +0200 Received: from poincare (poincare.swapping.umh.ac.be [10.102.100.111]) by hermes1.umh.ac.be (8.14.2/8.13.6) with ESMTP id o7NC04i6540794; Mon, 23 Aug 2010 14:00:04 +0200 Received: from localhost ([::1]) by poincare with esmtp (Exim 4.72) (envelope-from ) id 1OnVnG-0004sV-T9; Mon, 23 Aug 2010 14:06:26 +0200 Date: Mon, 23 Aug 2010 14:06:26 +0200 (CEST) Message-Id: <20100823.140626.634675953541672216.Christophe.Troestler+ocaml@umons.ac.be> To: burns.ethan@gmail.com Cc: caml-list@yquem.inria.fr, ruml@cs.unh.edu Subject: Re: [Caml-list] Question about float refs. From: Christophe TROESTLER In-Reply-To: References: X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoLKJBq0JBY9:}8v|j Organization: University of Mons Return-Receipt-To: Christophe.Troestler@umons.ac.be Disposition-Notification-To: Christophe.Troestler@umons.ac.be X-Mailer: Mew version 7.0.50 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; christophe:01 troestler:01 christophe:01 troestler:01 ocaml:01 printf:01 printf:01 unboxed:01 burns:98 wrote:01 rewrite:01 caml-list:01 minor:01 minor:01 umh:01 On Thu, 19 Aug 2010 07:52:33 -0400, Ethan Burns wrote: > > let r = ref 0.0 ;; > for i = 0 to 1000000000 do r := float i done; > Printf.printf "%f\n" !r; > Printf.printf "words: %f\n" (Gc.stat ()).Gc.minor_words To add a precision to others' answers : float refs are unboxed _locally_. If you rewrite your code as let r = ref 0.0 in for i = 0 to 1000_000_000 do r := float i done; Printf.printf "%f\n" !r; Printf.printf "words: %f\n" (Gc.stat ()).Gc.minor_words then it runs at about the same speed as you other version. My 0.02¤, C.