$ alias | grep 'alias time'alias time='/usr/bin/time -f "\nCPU: %Us\tReal: %es\tRAM: %MKB"'
$ time --version
GNU time 1.7
$ hhvm --version
HipHop VM 3.5.0 (rel) Compiler: 1422366928_06713107
$ time hhvm assoc.php
62810 62928 12261
356028 1118896 222001
CPU: 0.44s Real: 0.59s RAM: 96040KB
$ pacman -Q | grep ph7
ph7 2001004-1
$ time ph7 assoc.php
62810 62928 12261
356028 1118896 222001
CPU: 8.88s Real: 8.93s RAM: 112596KB
$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
$ time ruby hash.rb
62810 62928 12261
356028 1118896 222001
CPU: 0.51s Real: 0.53s RAM: 36424KB
$ rbx --version
rubinius 2.5.2.c85 (2.1.0 e8a24276 2015-02-23 3.5.1 JI) [x86_64-linux-gnu]
$ time rbx hash.rb
62810 62928 12261
356028 1118896 222001
CPU: 3.29s Real: 1.74s RAM: 119228KB
$ jruby --version
jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2015-02-24 2a3dc1f OpenJDK 64-Bit Server VM 24.75-b04 on 1.7.0_75-b13 +jit [linux-amd64]
$ time jruby hash.rb
62810 62928 12261
356028 1118896 222001
CPU: 8.77s Real: 3.83s RAM: 288472KB
$ iojs --version
v1.0.4
$ time iojs object.js
62810 62928 12261
356028 1118896 222001
CPU: 33.85s Real: 33.88s RAM: 55676KB
$ /opt/nodejs4/bin/node --version
v0.4.12
$ time /opt/nodejs4/bin/node object.js
62810 62928 12261
356028 1118896 222001
CPU: 16.77s Real: 16.80s RAM: 47124KB
$ node --version
v0.6.21-pre
$ time node object.js
62810 62928 12261
356028 1118896 222001
CPU: 16.96s Real: 16.92s RAM: 47128KB
$ node --version
v0.8.23
$ time node object.js
62810 62928 12261
356028 1118896 222001
CPU: 28.98s Real: 28.93s RAM: 50876KB
0.10.36-3
$ time node object.js
62810 62928 12261
356028 1118896 222001
CPU: 29.02s Real: 28.96s RAM: 51788KB
$ js24 --help | grep Version
Version: JavaScript-C24.2.0
$ time js24 object.js
62810 62928 12261
356028 1118896 222001
CPU: 0.34s Real: 0.35s RAM: 98480KB
$ pacman -Qo `which jsc-3`
/usr/bin/jsc-3 is owned by webkitgtk 2.4.8-1
$ time jsc-3 object.js
62810 62928 12261
356028 1118896 222001
CPU: 0.37s Real: 0.40s RAM: 87032KB
$ rhino < /dev/null
Rhino 1.7 release 4 2014 07 01
$ time rhino object.js
62810 62928 12261
356028 1118896 222001
CPU: 1.45s Real: 0.93s RAM: 179840KB
$ python3 --version
Python 3.4.2
$ time python3 dictionary.py
62810 62928 12261
356028 1118896 222001
CPU: 1.01s Real: 1.03s RAM: 40992KB
$ pypy --version
Python 2.7.8 (10f1b29a2bd2, Feb 05 2015, 16:50:17) [PyPy 2.5.0 with GCC 4.9.2 20141224 (prerelease)]
$ time pypy dictionary.py
(62810, 62928, 12261)
(356028, 1118896, 222001)
CPU: 0.31s Real: 0.32s RAM: 102660KB
$ go version
go version go1.4.1 linux/amd64
$ rm -f map; time go run map.go
62810 62928 12261
356028 1118896 222001
CPU: 0.27s Real: 0.29s RAM: 39340KB
$ lua -v
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
$ time lua table.lua
62810 62928 12261
356028 1118896 222001
CPU: 0.60s Real: 0.62s RAM: 26692KB
$ luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall.
$ time luajit table.lua
62810 62928 12261
356028 1118896 222001
CPU: 0.40s Real: 0.42s RAM: 19436KB
$ dart --version
Dart VM version: 1.8.5 (Tue Jan 13 12:44:14 2015) on "linux_x64"
$ time dart map.dart
62810 62928 12261
356028 1118896 222001
CPU: 0.31s Real: 0.34s RAM: 95780KB
And the summary
Compiler / Interpreter | Language | Type Name | Data Structure | Runtime Duration | Runtime RAM |
hhvm | PHP 5.4 | array | Hash Table | 440 | 96040 |
ph7 | PHP 5.3 | array | Hash Table | 8880 | 112596 |
ruby | Ruby | Hash | Hash Table | 510 | 36424 |
rbx | Ruby | Hash | Hash Table | 3290 | 119228 |
jruby | Ruby | Hash | Hash Table | 3830 | 288472 |
iojs | JavaScript ES6 | Object | Unknown | 33850 | 55676 |
node (0.4) | JavaScript | Object | Unknown | 16770 | 47124 |
node (0.6) | JavaScript | Object | Unknown | 16960 | 47128 |
node (0.8) | JavaScript | Object | Unknown | 28980 | 50876 |
node (0.10) | JavaScript | Object | Unknown | 29020 | 51788 |
js24 | JavaScript | Object | Unknown | 340 | 98480 |
jsc-3 | JavaScript | Object | Unknown | 370 | 87032 |
rhino | JavaScript | Object | Unknown | 1450 | 179840 |
python3 | Python 3 | dict | Hash Table | 1010 | 40992 |
pypy | Python 2 | dict | Hash Table | 310 | 102660 |
go | Go | map | Hash Table | 270 | 39340 |
lua | Lua | table | Hash Table | 600 | 26692 |
luajit | Lua | table | Hash Table | 400 | 19436 |
dart | Dart | Map | Hash Table | 310 | 95780 |
Note #1: Apparently my previous code for Python, JavaScript and PHP were wrong because I forgot to round the floating point division, I have updated the previous benchmark result.
Note #3: I/O JS and NodeJS seems fast to build the associative array, but awfully slow when iterating array
No comments:
Post a Comment
THINK: is it True? is it Helpful? is it Inspiring? is it Necessary? is it Kind?