On 10/10/2015 17:45, Artella Coding wrote:
I get double speedup using the new ffi (see timings at top of files below). Strangely passing integers by ref is actually slower than passing by value (see last program right at the bottom) :
I'm not actually surprised that passing by reference is slower. The format of values is very different between ML and C so passing by reference actually involves extra work. In fact it's really call by value-result because the current value of the ref is copied into a new C variable and after the function is called the result is copied back.
I am, though, surprised that it is as significant as it is and I can't really see why it should be.
David