Sunday, 29 May 2016

Language benchmarking - Update with memory consumption

Like some sort of amateur I totally missed the opportunity to calculate memory consumption in addition (maximum resident set size) in addition to CPU usage.

As I'm using the gtime (gnu time) command on Mac OS X I can use the %M format specifier.

So, with literally 3 seconds of find/replace I've updated my benchmarks and present the results here below.

PS. As my next project is going to be based around 2D vector graphics I'm going to do some performance comparisons of several languages - likely a much reduced set though, Haskell for instance doesn't really lend itself to lots of side effects. I'll probably do a collection of graphics primitives and measures FPS or time per frame. Watch this space!

Edit: I just realised I was running a very old version of the rust compiler (1.1.0), I've just upgraded to 1.9.0 and rerun the results. The old number is in parentheses.

Language Real User Sys Working Set (MB)
Rust 0.12.05
(0:12.47)
11.47
(11.94)
0.17
(0.14)
4.875
(5.98)
C++ 0:12.73 12.05  0.21 191.33
Monkey-X 0:15.84 15.17 0.24 517.59
PyPy2 0:16.76 16.11 0.20 313.17
Go 0:23.41 23.19 0.17 24.55
BlitzMax 0:24.87 23.99 0.24 27.76
C# 0:27.87 26.50 0.60 282.44
Java 0:30.41 30.43 0.25 428.95
Scala 0:31.63 31.25 0.66 2804.08
D 0:32.22 31.98 0.15 9.20
PyPy3 0:32.44 31.34 0.34 278.56
Haskell 0:38.96 38.27 0.50 2088.64
O'Caml 0:43.50 43.19 0.20 16.64
F# Mono 0:58.05 57.32 0.52 144.59
Clojure 1:01.01 62.52 1.01 2306.17
C# Mono 1:01.38 58.84 0.83 128.00
Ruby 2:31.46 149.54 0.54 28.91
Python2 4:46.03 282.67 1.43 26.38
Python3 4:26.41 264.80 0.72 33.45

I've also put a funky chart together - left is faster, the taller the bar the higher the memory consumption.

Rust appears to be some sort of perfect language for this. Very interesting.