Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2001-12-11 (21:09)
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:  FAQ:
To unsubscribe, mail  Archives: