English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
How to read different ints from a Bigarray?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-10-29 (18:42)
From: Christophe TROESTLER <Christophe.Troestler+ocaml@u...>
Subject: Re: [Caml-list] How to read different ints from a Bigarray?
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).