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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B8A93BC37 for ; Thu, 29 Oct 2009 19:42:39 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag4FANZ+6UrUNQVbcWdsb2JhbACbSAEMCA0HE8NuhD0EgWI X-IronPort-AV: E=Sophos;i="4.44,647,1249250400"; d="scan'208";a="35835595" Received: from postbode01.versateladsl.be ([212.53.5.91]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Oct 2009 19:42:39 +0100 Received: (qmail 6868 invoked by uid 0); 29 Oct 2009 18:41:43 -0000 Received: from unknown (HELO poincare.swapping.umh.ac.be) ([94.109.153.156]) (envelope-sender ) by smtp.versateladsl.be (qmail-ldap-1.03) with SMTP for < >; 29 Oct 2009 18:41:43 -0000 Received: from [127.0.0.1] (helo=localhost ident=trch) by poincare.swapping.umh.ac.be with esmtp (Exim 4.69) (envelope-from ) id 1N3ZxE-0001IW-Qs; Thu, 29 Oct 2009 19:42:36 +0100 Date: Thu, 29 Oct 2009 19:42:36 +0100 (CET) Message-Id: <20091029.194236.1084429741786009945.Christophe.Troestler+ocaml@umons.ac.be> To: caml-list@inria.fr Subject: Re: [Caml-list] How to read different ints from a Bigarray? From: Christophe TROESTLER In-Reply-To: <87pr86b066.fsf@frosties.localdomain> References: <87eiond3of.fsf@frosties.localdomain> <4AE87AB9.5020607@inria.fr> <87pr86b066.fsf@frosties.localdomain> 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 6.3rc1 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 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.