Browse thread
[Caml-list] c is 4 times faster than ocaml?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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 that.) 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 caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners