Eccentric Developments


Raybench - JavaScript (PLC pt.4)

JavaScript is the de facto language of the web. All major browsers support it and can also be run on servers and desktop computers using node.js.

Syntax is similar to C/C++ language making it easy to learn, but offers much more flexibility. Functions can be passed around asparameters and assigned to variables (like Lua), and allows programming asynchronous execution of functions.

There is a lot of development on the most widely used interpreters for this language, offering great performance; so good that you might get as surprised as I got while comparing the results with implementations in other languages.

Results

Tests where run using node.js v5.7.1

Loading time

$ time node jsrb.js

real    0m1.755s
user    0m0.156s
sys     0m0.016s

Loading time is much slower than lua (and luajit).

Running time

$ time node jsrb.js 

real    8m49.170s
user    8m40.620s
sys     0m4.488s

This was an unexpected result, JavaScript code running on top of node.js is a bit over 4 times slower than compiled C code. Compared to Lua, JavaScript is lightning fast.

Code metrics Line count: 250 code, 63 blank, 313 total File size: 6175 bytes

General Thoughts

This is a good surprise; as can be seen, the arduous work of optimization done to Google's V8 Engine has really paid off.

No wonder why node.js is used as the backend for several websites and web services' APIs.

Follow

You can follow the development of this project on GitHub: https://github.com/niofis/raybench

Enrique CR - 2016-05-05