Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Pairs vs. Records
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Pairs vs. Records
> I had a progarm that used pairs int*int as the basis of the primary data
> structure.  After changing it to use records {row:int;col:int} the
> program runs slower.

This is very surprising indeed, because the OCaml compilers generate
*exactly the same code* for building/accessing tuples and for
building/accessing records (with no mutable fields).

(Actually, this isn't quite right: records of floats are optimized
specially, but not tuples of floats.)

So, I'd look elsewhere for the cause of the performance loss.  Notice
that with modern processors, even tiny changes in the code (such as
deleting or adding unused functions) can result in noticeable (and
highly unpredictable...) performance differences, because of code
placement effects.

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr