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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 75F36BC37 for ; Thu, 29 Oct 2009 20:03:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhICAEuD6UrZSMDqkWdsb2JhbACBT5l5AQEBAQkLCgcTA8NvhD0EgWKJaQ X-IronPort-AV: E=Sophos;i="4.44,647,1249250400"; d="scan'208";a="49481771" Received: from fmmailgate03.web.de ([217.72.192.234]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Oct 2009 20:03:19 +0100 Received: from smtp08.web.de (fmsmtp08.dlan.cinetic.de [172.20.5.216]) by fmmailgate03.web.de (Postfix) with ESMTP id 783E112C8E029; Thu, 29 Oct 2009 20:03:18 +0100 (CET) Received: from [95.208.117.111] (helo=frosties.localdomain) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1N3aHE-0005vx-00; Thu, 29 Oct 2009 20:03:16 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1N3aHE-00053f-0u; Thu, 29 Oct 2009 20:03:16 +0100 From: Goswin von Brederlow To: Christophe TROESTLER Cc: caml-list@inria.fr Subject: Re: [Caml-list] How to read different ints from a Bigarray? References: <87eiond3of.fsf@frosties.localdomain> <4AE87AB9.5020607@inria.fr> <87pr86b066.fsf@frosties.localdomain> <20091029.194236.1084429741786009945.Christophe.Troestler+ocaml@umons.ac.be> Date: Thu, 29 Oct 2009 20:03:15 +0100 In-Reply-To: <20091029.194236.1084429741786009945.Christophe.Troestler+ocaml@umons.ac.be> (Christophe TROESTLER's message of "Thu, 29 Oct 2009 19:42:36 +0100 (CET)") Message-ID: <87eiomowek.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.22 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+pQt5fO+44Q0gL3H6LkGQhcvU/V4CAUcN8wZFD K4m6z+V2ccVwjoqRf71LFs2VzmJRYs3e2ZuOBKXUaZzCZC7TaB CbVMQY7rw= X-Spam: no; 0.00; bigarray:01 christophe:01 troestler:01 christophe:01 troestler:01 ocaml:01 0100,:01 ocaml:01 bigarray:01 allocating:01 bigarrays:01 c-c:01 emacs:01 compiler:01 elt:01 Christophe TROESTLER writes: > On Thu, 29 Oct 2009 18:05:37 +0100, Goswin von Brederlow wrote: >> >> get an int out of a string: >> C Ocaml >> uint8 le 19.496 17.433 >> int8 le 19.298 17.850 >> uint16 le 19.427 25.046 >> int16 le 19.383 27.664 >> uint16 be 20.502 23.200 >> int16 be 20.350 27.535 >> >> get an int out of a Bigarray.Array1.t: >> safe unsafe >> uint8 le 55.194s 54.508s >> uint64 le 80.51s 81.46s >> >> The Bigarray unsafe_get is really disapointing. Note that uint64 is so >> much slower because of allocating the result (my guess). Array1.set >> runs the same speed for uint8 and uint64. > > This is likely because you used the polymorphic function to access > bigarrays (compile your code with -annot and press C-c C-t in Emacs > with the point on the variable). For the compiler to be able to emit > fast code, you need to provide the monomorphic type of the bigarray: > > (a: (int, int8_unsigned_elt, c_layout) Array1.t) > > (assuming you opened the Bigarray module). > > Cheers, > C. Wow, you are right. Down to 14.919s. String.unsafe_get, which actualy does exist despite not being documented, gets 14.843s. So basically the same. MfG Goswin