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] c is 4 times faster than ocaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-08-04 (05:05)
From: John Prevost <j.prevost@g...>
Subject: Re: [Caml-list] c is 4 times faster than ocaml?
Oh, one last parting thought:

Part of why gcc is winning here is that it's actively working with the
fact that the loop variable, the index, and the value to be inserted
are the same value.  O'Caml is doing extra work because it's not
linking them up (it could at the very least avoid shifting a few
registers around and avoid an extra sarl instruction if it did spot

But this is the trouble with artificial benchmarks: no real code is
simply going to be copying the loop value into the array.  It's going
to be fetching the value from somewhere else, probably by doing
pointer arithmetic on the loop value and the source address, then it
will do pointer arithmetic on the loop value and the destination
address.  Then it will set the result.  A smart C coder will do the
arithmetic ahead of time, which means incrementing two values instead
of one each time through the loop, but wins overall.  Anyway, the
short is: artificial benchmarks are bad.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: