Below table shows the benchmark results for reading 10 times 10000 values and 10000 times 10 values with links to the source code files in the different programming languages:
|Language||10 times 10000 values||10000 times 10 values|
|F#||6 seconds||20 seconds|
|Python||26 seconds||40 seconds|
|Julia||45 seconds||72 seconds|
|Go||8 seconds||25 seconds|
|OCaml||2.5 seconds||48 seconds|
The overall fastest version is the one written in F# but note that it's also the version I have tweaked the most. As I'm not very experienced in most of the languages so any performance tips are welcome. Note that I tried using memory mapped files in .NET and Python this improved performance when querying lots of values from the same file but also made it worse in other cases.
The implementation of the functionality is most of the times rather similar in the different languages. Some notable differences where:
- Julia apparently doesn't have a null value so I refrained from checking whether the read integer value was equal to the int32 minimum value (-2147483648).
- In Go converting the bytes to integers was faster with a custom function.
- I didn't find a function in the OCaml Core library to convert bytes to a 32-bit integer, but luckily I found one on Stack Overflow.
Any suggestions for improving the implementation in one of the above programming languages ? Which language would you like to compare my results with ? Which other language(s) do you expect to be faster than my benchmark results ? Can you help me out with a version in your favorite language or in C, fortran, Common Lisp, Scheme, Clojure, Java or J ?