I noticed that PolyML FFI (v5.6, Foreign structure) 100 times slower than MLton and Haskell FFI, and 10 times than Perl. :-( But why? After all, Haskell uses also libffi...
P.S.
I used buildCall3 ((getSymbol libc "foo"), (cUlong, cString, cUint), cUlong) (0, s, String.size s) and buildCall3 ((getSymbol libc "foo"), (cUlong, cPointer, cUint), cUlong) (0, s, String.size s) for test.
Nick.