Christophe TROESTLER <christophe.troestler+oc...@umons.ac.be> 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

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to