Showing posts with label luajit. Show all posts
Showing posts with label luajit. Show all posts

2018-09-13

String Associative Array Benchmark 2

Redoing old string associative benchmark (3 years ago) but now on Macbook Pro MJLQ2, here's the result:

alias time='/usr/local/bin/gtime -f "\nCPU: %Us\tReal: %es\tRAM: %MKB"'

$ java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
$ time javac hash_map.java
CPU: 1.22s Real: 0.60s RAM: 67540KB
$ time java hash_map
6009354 6009348 611297
36186112 159701682 23370001
CPU: 274.83s Real: 53.47s RAM: 3946268KB

$ go version
go version go1.10.2 darwin/amd64

$ go build map.go
CPU: 0.09s Real: 0.14s RAM: 16160KB
$ time ./map
6009354 6009348 611297
36186112 159701682 23370001
CPU: 29.55s Real: 22.12s RAM: 2425316KB

$ dart --version
Dart VM version: 2.0.0 (Fri Aug 3 10:53:23 2018 +0200) on "macos_x64"

$ time dart ./map.dart
6009354 6009348 611297
36186112 159701682 23370001
CPU: 59.29s Real: 60.08s RAM: 1763952KB

$ node --version
v10.10.0
$ time node object.js # ERROR: TOO SLOW
^CCommand terminated by signal 2 
CPU: 855.68s Real: 763.40s RAM: 1517576KB

$ php -version
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
$ time php -d memory_limit=4G assoc.php
6009354 6009348 611297
36186112 159701682 23370001
CPU: 26.76s Real: 27.89s RAM: 1297824KB

$ mcs --version
Mono C# compiler version 5.10.1.0
$ time mcs dictionary.cs
CPU: 0.21s Real: 0.32s RAM: 42564KB
$ time mono ./dictionary.exe
6009354 6009348 611297
36186112 159701682 23370001
CPU: 33.69s Real: 33.64s RAM: 1609576KB

$ ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
$ time ruby hash.rb
time ruby hash.rb
6009354 6009348 611297
36186112 159701682 23370001
CPU: 100.57s Real: 103.63s RAM: 3012148KB

$ jruby --version
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.172-b11 on 1.8.0_172-b11 +jit [darwin-x86_64]
$ time jruby hash.rb # ERROR: TOO MEMORY CONSUMING
Error: Your application used more memory than the automatic cap of 3641MB.
Specify -J-Xmx####M to increase it (#### = cap size in MB).
Specify -w for full java.lang.OutOfMemoryError: GC overhead limit exceeded stack trace
Command exited with non-zero status 1
CPU: 1616.55s Real: 257.91s RAM: 4439172KB

$ python3 --versionPython 3.7.0
$ time python3 dictionary.py
6009354 6009348 611297
36186112 159701682 23370001
CPU: 117.59s Real: 121.63s RAM: 3923812KB

$ pypy --version
Python 2.7.13 (ab0b9caf307db6592905a80b8faffd69b39005b8, Jun 24 2018, 08:19:27)[PyPy 6.0.0 with GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
$ time pypy dictionary.py
(6009354, 6009348, 611297)
(36186112, 159701682, 23370001)
CPU: 28.82s Real: 31.55s RAM: 3993764KB

$ lua -v
Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio
$ time lua table.lua
6009354 6009348 611297
36186112 159701682 23370001
CPU: 89.05s Real: 91.35s RAM: 2523332KB

$ luajit -v
LuaJIT 2.0.5 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
$ time luajit table.lua # ERROR: CANNOT ALLOC MEMORY
PANIC: unprotected error in call to Lua API (not enough memory)
Command exited with non-zero status 1CPU: 30.57s Real: 31.56s RAM: 1132648KB

This time PHP7 became the best performing programming language implementation, also the least memory consumption (I'm amazed with what they did in version 7). And as usual LuaJIT limited to 1-2GB so they failed, NodeJS too slow, and I'm unwilling to wait more than 10 minutes, so I terminate the app, JRuby hogging RAM too much.


LanguageVersionCompile DurationCompile RAMRuntime DurationRuntime RAM2015's Duration2015's RAMDuration ImprovRAM Improv
C#5.10.1.00.3242,56433.641,609,57640.981,690,22417.91%4.77%
Dart2.0.060.081,763,952133.352,538,22054.95%30.50%
Go1.10.20.1416,16022.122,425,31624.102,748,7848.22%11.77%
Java1.8.0_1720.6067,54053.473,946,268103.544,119,38848.36%4.20%
Lua5.3.591.352,523,332101.733,079,33610.20%18.06%
PHP7.1.1627.891,297,824failedfailed
Pypy6.0.031.553,993,76479.874,034,95660.50%1.02%
Python33.7.0121.633,923,812157.714,335,56822.88%9.50%
Ruby2.3.7p456103.633,012,148107.913,031,8723.97%0.65%

2016-12-01

Faster than Go? Yes, plenty

Is there anything that faster than Go? yes, there are plenty, but I'm not sure if it would be fun to code with.. What are they?

G-WAN

G-WAN is closed-source web application server (not a language like Go). If I'm not mistaken G-WAN caches GET request, so second hit within few ms won't execute the backend function, practically this is cheating for benchmark (not merged), but for real application this feature quite great (can cope up with DDOS attack) :3 Btw did I mention that this web application server support whole lot of language? asm, C, C++, C#, D, Go, Java, Javascript, Lua, Objective-C, Perl, PHP, Python, Ruby, and Scala with CGI-like writing. One note that you must really learn how HTTP works (parsing header, setting cookie, parsing POST parameters, etc) if you want to use this.


I don't really know if this suffer the same problem similar to others that use CGI instead of FastCGI: connection pooling to database (but we can use pgpool).

LWAN

LWAN is also web application server that uses C, can be used with LuaJIT (fast implementation of Lua). For the framework you can use Sailor (Example).



PyParallel 

PyParallel is a programming language implementation, forked from Python3, removes GIL (Global Interpreter Lock).


Julia

Julia is one awesome programming language that uses LLVM, it focuses


Actually there's a lot more implementation that faster than Go for certain (or all) cases, such as: C, C++, Ada, Rust, Java, and Fortran, be sure to check on BenchmarkGame site.


But, don't choose a language or web framework or web application platform just based on performance, there's a lot of things to consider, for example:
  • either it's waste of time to work with (since you must do many things manually aka there's no framework or so little libraries/function yet)
  • how easy it's to train a new programmer to work with you or continue the project
  • what's the continuity of the technology (if the project abandoned by the author/maintainer)
  • build/compile duration
  • etc..
If you are looking for next hype? try Elixir and Phoenix.

2015-02-26

Numeric CombSort Benchmark update!

As I've written before, CombSort are quite good sort algorithm. Let's compare this algorithm when implemented in various programming language. The benchmark should not use any other built-in function other than array generation and printing. The benchmark uses AMD A8-6600K, 16GB RAM with Non-SSD disk.

$ alias | grep 'alias time'
alias time='/usr/bin/time -f "\nCPU: %Us\tReal: %es\tRAM: %MKB"'
$ time --version
GNU time 1.7

g++ --version
g++ (GCC) 4.9.2 20141224 (prerelease)
$ time g++ comb.cpp
CPU: 0.05s      Real: 0.12s     RAM: 19428KB
$ time ./a.out
CPU: 1.94s      Real: 1.97s     RAM: 79804KB
$ time g++ -O2 comb.cpp
CPU: 0.07s      Real: 0.11s     RAM: 21260KB
$ time ./a.out
CPU: 0.88s      Real: 0.90s     RAM: 79804KB

clang --version
clang version 3.5.1 (tags/RELEASE_351/final)
$ time clang++ comb.cpp
CPU: 0.05s      Real: 0.08s     RAM: 33564KB
$ time ./a.out
CPU: 1.83s      Real: 1.86s     RAM: 79764KB
$ time clang++ -O2 comb.cpp
CPU: 0.08s      Real: 0.14s     RAM: 37860KB
$ time ./a.out
CPU: 0.89s      Real: 0.91s     RAM: 79804KB

java -version
java version "1.7.0_71" 
$ time javac comb.java
CPU: 1.05s      Real: 0.73s     RAM: 65952KB
$ time java comb
CPU: 1.32s      Real: 1.32s     RAM: 110488KB

php --version
PHP 5.6.4 (cli) (built: Dec 17 2014 21:45:04)
$ time php comb.php
CPU: 102.69s    Real: 104.20s   RAM: 2497508KB

hhvm --version
HipHop VM 3.5.0 (rel)
$ time hhvm -v Eval.Jit=true comb.php 
CPU: 12.56s     Real: 14.83s    RAM: 362488KB

ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ time ruby comb.rb
CPU: 52.87s     Real: 53.02s    RAM: 87892KB

rbx --version
rubinius 2.5.2 (2.1.0 7a5b05b1 2015-01-30 3.5.1 JI) [x86_64-linux-gnu]
$ time rbx comb.rb
CPU: 74.89s     Real: 74.30s    RAM: 135320KB

node --version
v0.10.35
$ time node comb1.js
CPU: 2.64s      Real: 2.64s     RAM: 92240KB
$ time node comb2.js
CPU: 2.68s      Real: 2.72s     RAM: 140612KB

rhino < /dev/null 
Rhino 1.7 release 4 2014 07 01
$ rhino comb2.js
CPU: 87.39s     Real: 61.16s    RAM: 1993848KB

$ pacman -Qo `which jsc-3`
/usr/bin/jsc-3 is owned by webkitgtk 2.4.8-1
$ time jsc-3 comb1.js
CPU: 23.74s     Real: 23.93s    RAM: 93740KB
$ time jsc-3 comb2.js
CPU: 18.99s     Real: 19.16s    RAM: 181644KB

js24 --help | grep Version
Version: JavaScript-C24.2.0
$ time js24 --ion-eager comb1.js
CPU: 2.13s      Real: 2.15s     RAM: 89688KB
$ time js24 --ion-eager comb2.js
CPU: 1.53s      Real: 1.58s     RAM: 92384KB

go version
go version go1.4.1 linux/amd64
$ time go build comb.go 
CPU: 0.14s      Real: 0.17s     RAM: 31568KB
$ time ./comb
CPU: 1.10s      Real: 1.14s     RAM: 79824KB

rustc --version
rustc 1.0.0-dev
$ time rustc comb.rs
CPU: 0.39s      Real: 0.49s     RAM: 106844KB
$ time ./comb
CPU: 10.62s     Real: 10.71s    RAM: 86020KB
$ time rustc -O comb.rs
CPU: 0.41s      Real: 0.49s     RAM: 110204KB
$ time ./comb
CPU: 0.97s      Real: 0.99s     RAM: 86108KB

scala -version
Scala code runner version 2.11.5 -- Copyright 2002-2013, LAMP/EPFL
$ time scala comb.scala
CPU: 5.43s      Real: 6.30s     RAM: 206088KB
$ time scalac comb.scala
CPU: 10.62s     Real: 7.00s     RAM: 143460KB
$ time scala Comb
CPU: 5.49s      Real: 5.05s     RAM: 206300KB

python --version
Python 3.4.2
$ time python comb1.py
CPU: 90.47s     Real: 90.83s    RAM: 403192KB
$ time python comb2.py
CPU: 106.82s    Real: 107.26s   RAM: 87248KB

pypy --version
Python 2.7.8 (c6ad44ecf5d8, Nov 18 2014, 18:04:31) [PyPy 2.4.0 with GCC 4.9.2]
$ time pypy comb1.py
CPU: 5.34s      Real: 5.40s     RAM: 136764KB
$ time pypy comb2.py
CPU: 5.85s      Real: 6.04s     RAM: 204588KB

mcs --version
Mono C# compiler version 3.12.0.0
$ time mcs -o+ comb.cs
CPU: 0.44s      Real: 0.47s     RAM: 45908KB
$ time ./comb.exe
CPU: 1.38s      Real: 1.41s     RAM: 90472KB

lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
$ time lua comb.lua
CPU: 65.64s     Real: 65.81s    RAM: 264096KB

luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall.
$ time luajit comb.lua
CPU: 6.30s      Real: 6.34s     RAM: 132964KB

dart --version
Dart VM version: 1.8.5 (Tue Jan 13 12:44:14 2015) on "linux_x64"
$ time dart scomb.dart
CPU: 2.12s      Real: 2.24s     RAM: 93392KB

The code can be found on my dropbox (folder: num-comb), and here's the summary:

Compiler / InterpreterLanguageCompile DurationCompile RAMRuntime DurationRuntime RAMTotal Duration
g++ (debug)C++50194281940798041990
g++ (-O2)C++702126088079804950
clang++ (debug)C++50335641830797641880
clang++ (-O2)C++803786089079804970
javac, javaJava10506595213201104882370
phpPHP1026902497508102690
hhvmPHP1256036248812560
rubyRuby528708789252870
rbxRuby7489013532074890
node (typed array)Javascript2640922402640
node (untyped array)Javascript26801406122680
rhino (untyped array)Javascript87039199384887039
jsc-3 (typed array)Javascript237409374023740
jsc-3 (untyped array)Javascript1899018164418990
js24 (typed array)Javascript2130896882130
js24 (untyped array)Javascript1530923841530
goGo140315681100798241240
rustc (debug)Rust390106844106208602011010
rustc (-O2)Rust410110204970861081380
scalaScala54302060885430
python3Python 39047040319290470
python3 (array)Python 310682087248106820
pypyPython 253401367645340
pypy (array)Python 258502045885850
mcsC#440459081380904721820
luaLua6564026409665640
luajitLua63001329646300
dartDart2120933922120

Write down your opinion (or pastie if you found a bug on these source, or if you want to add more language implementation) on the comment section ^^)b

Note #1Opal (0.6.8) and JRuby (both 1.7.18 and 9.0.0pre1) failed to run this benchmark (they exceed 300s runtime limit even when using -J-Xmx3000M -J-Djruby.compile.mode=FORCE flag).

Note #2: Yes, it's unfair to compare array of integer and array of double, life is unfair by design, get over it...

String CombSort Benchmark update!

Previously, we have benchmark CombSort algorithm implemented in various programming language for array of number. Let's compare this algorithm with addition integer to string conversion the language's built-in string library. The benchmark should not use any other built-in function other than string, integer conversion and array generation and printing. The benchmark uses AMD A8-6600K, 16GB RAM with Non-SSD disk.

$ alias | grep 'alias time'
alias time='/usr/bin/time -f "\nCPU: %Us\tReal: %es\tRAM: %MKB"'
$ time --version
GNU time 1.7

g++ --version
g++ (GCC) 4.9.2 20141224 (prerelease)
$ time g++ -std=c++11 scomb.cpp
CPU: 0.18s      Real: 0.20s     RAM: 35868KB
$ time ./a.out
CPU: 19.32s     Real: 19.60s    RAM: 548912KB
$ time g++ -std=c++11 -O2 scomb.cpp
CPU: 0.20s      Real: 0.24s     RAM: 38184KB
$ time ./a.out
CPU: 13.76s     Real: 14.05s    RAM: 548816KB

clang --version
clang version 3.5.1 (tags/RELEASE_351/final)
$ time clang++ -std=c++11 scomb.cpp
CPU: 0.15s      Real: 0.20s     RAM: 42240KB
$ time ./a.out
CPU: 18.89s     Real: 19.21s    RAM: 548868KB
$ time clang++ -std=c++11 -O2 scomb.cpp
CPU: 0.20s      Real: 0.23s     RAM: 45824KB
$ time ./a.out
CPU: 13.87s     Real: 14.15s    RAM: 548820KB

javac -version
javac 1.7.0_71
$ time javac scomb.java
CPU: 1.13s      Real: 0.80s     RAM: 65324KB
$ time java scomb
CPU: 48.96s     Real: 27.59s    RAM: 906652KB

hhvm --version
HipHop VM 3.5.0 (rel)
$ time hhvm -v Eval.Jit=true scomb.php
CPU: 89.92s     Real: 90.38s    RAM: 877468KB

ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ time ruby scomb.rb
CPU: 114.67s    Real: 115.21s   RAM: 870612KB

node --version
v0.10.35
$ time node scomb.js
CPU: 17.44s     Real: 17.41s    RAM: 411144KB

$ pacman -Qo `which jsc-3`
/usr/bin/jsc-3 is owned by webkitgtk 2.4.8-1
$ time jsc-3 scomb.js
CPU: 60.08s     Real: 43.66s    RAM: 834744KB

js24 --help | grep Version
Version: JavaScript-C24.2.0
$ time js24 scomb.js
CPU: 19.27s     Real: 19.62s    RAM: 735556KB

go version
go version go1.4.1 linux/amd64
$ time go build scomb.go
CPU: 0.14s      Real: 0.17s     RAM: 30428KB
$ time ./scomb
CPU: 11.45s     Real: 11.54s    RAM: 251628KB

scala -version
Scala code runner version 2.11.5 -- Copyright 2002-2013, LAMP/EPFL
$ time scala -J-Xmx3000M scomb.scala
CPU: 83.42s     Real: 46.10s    RAM: 1093924KB

python --version
Python 3.4.2
$ time python scomb.py
CPU: 121.33s    Real: 122.06s   RAM: 641844KB

pypy --version
Python 2.7.8 (c6ad44ecf5d8, Nov 18 2014, 18:04:31) [PyPy 2.4.0 with GCC 4.9.2]
$ time pypy scomb.py
CPU: 14.72s     Real: 14.97s    RAM: 522080KB

lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
$ time lua scomb.lua
CPU: 98.11s     Real: 98.54s    RAM: 863880KB

luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall.
$ time luajit scomb.lua
CPU: 21.30s     Real: 21.61s    RAM: 511268KB

dart --version
Dart VM version: 1.8.5 (Tue Jan 13 12:44:14 2015) on "linux_x64"
$ time dart scomb.dart
CPU: 11.92s     Real: 12.15s    RAM: 497788KB

The code can be found on my dropbox (folder: str-comb), and here's the summary:

Compiler / InterpreterLanguageCompile DurationCompile RAMRuntime DurationRuntime RAMTotal Duration
g++ (debug)C++180358681932054891219500
g++ (-O2)C++200381841376054881613960
clang++ (debug)C++150422401889054886819040
clang++ (-O2)C++200458241387054882014070
javac, javaJava1130653244896090665250090
hhvmPHP8992087746889920
rubyRuby114670870612114670
nodeJavascript1744041114417440
jsc-3Javascript6008083474460080
js24Javascript1927073555619270
goGo140304281145025162811590
scalaScala83420109392483420
python3Python 3121330641844121330
pypyPython 21472052208014720
luaLua9811086388098110
luajitLua2130051126821300
dartDart1192049778811920

Write down your opinion (or pastie if you found a bug on these source, or if you want to add more language implementation) on the comment section ^^)b

Note #1PHP 5.6.4, Rubinius 2.5.2, JRuby 9.0.0a1, Rhino 1.7, MCS 3.12 failed to end their execution within approx. 120s timeout