Tuesday, 3 September 2013

Hash table insertion performance: F# vs OCaml vs Haskell

Time taken to insert ten million int→T bindings for T as each of int, float, complex and string using F# on .NET 4.5, OCaml 3.12 and GHC 7.4.2:
On a 3.4GHz Intel Core i7-3770 running Windows 7.
Value types and reified generics facilitate .NET's very efficient Dictionary implementation when handling value types like int, float and complex (unmatched by any other language/VM including C, C++ and Java). F# is 50% faster than OCaml and Haskell using the reference type string perhaps because the .NET write barrier is significantly more efficient.
Note: we use "int" to refer to ordinary 32-bit ints in F# and Haskell but 31-bit ints in OCaml. Using 32-bit ints in OCaml would be much slower because they are boxed (i.e. heap allocated).


Unknown said...

Can you post code example?

rmouniak said...

Nice post, Thanks for sharing Get more update at
.Net Online Course