tl;dr - Depending on whether you use Node.js or io.js, you may experience performance differ by a factor of more than 5 for identical code.

First of all, let me make something clear. This is not, and cannot be, a comprehensive test. Every application is different. Depending on what your Node application does, my findings may or may not apply to your use-case.

What I tested

In a previous article I tested the performance of a very simple algorithm for finding prime-numbers, theSieve of Eratosthenes, in C, Java, JavaScript and FreePascal. To test JavaScript I used Node and chose three different ways of implementing this algorithm, using a regular array, typed-array or buffer.




前面的文章中,我使用C,JAVA,Javascript和FreePascal测试了一个很简单的算法性能寻找prime-numbers和Sieve of Eratosthenes。为了测试Javascript,我基于Node选择三种不同的实现算法,包括普通阵列,输入阵列或缓冲。

Today I want to use the same benchmark to show how much performance can vary betweenNode.js and io.js. For those of you who don't know it yet, io.js is a fork of Node.

I will use the same code as in my previous article. You can find it at the end of that article.

Node and io.js have one important thing in common. They both rely on Chrome'sV8 JavaScript Engine. But they use different versions of V8. So when I'm comparing Node and io.js, I'm actually comparing the different versions of Chrome's V8 JavaScript Engine they use.

For my previous test I used Node 0.10.32 as that is the one that comes with OpenSuse 13.2, the Linux distribution that I'm using. But for today's test I will use Node 0.10.35 and io.js 1.0.2 as these are the latest available releases. And yes, I am aware that io.js describes that release as "unstable". But it's all I've got. :)



Node和io.js有一个重要的共同点。他们都依赖于Chrome的V8 Javascript引擎。但是他们使用的是不同的V8版本。所以,当我们比较Node和IO.js的时候,其实我是比较他们使用的不同版本的Chrome V8 JavaScript引擎。

在我的前一个测试中,我用的Node0.10.32,因为这是我使用的Linux发新版OpenSuse13.2自带的。但是在今天的测试中,我将使用Node 0.10.35和io.js 1.0.2,因为他们是最新的发布版。是的,我知道io.js描述该版本为“不稳定”,但它是我唯一能获取的版本。

Just as I did for my previous article, I ran each test 7 times and then used themedian time as my result. I was running the tests on an Intel i7-4771 3,5GHz using a 64-bit OpenSuse 13.2.

Here are the results:

Node.js 0.10.35io.js 1.0.2
Regular Array40.4167.359

(Times are listed in seconds)

As you can see, the performance for typed-array and regular array varies quite dramatically.

Using a buffer, io.js takes almost 18% longer than Node. Not nice to see, but not something to really worry about.

The typed-array test takes more than twice as long with io.js than with Node. Now that is a pretty significant difference.

But with regular arrays it is the other way around, and even more pronounced. Here Node takes more than 5x as long as io.js.

以运行在Intel i7-4771 3.5GHz上的64位OpenSuse 13.2系统为测试环境(作者话痨,还顺带提了一下自己之前写的文章中也用了同样的方法),前后测试了7次,测试结果(时间)取中位数,结果如下:

Node.js 0.10.35      io.js 1.0.2
Buffer 4.259 5.006
Typed-Array 4.944 11.555
Regular Array    40.416 7.359


如你所见,Node和io.js对typed-array和regular array处理的性能的变化让人瞠目。



对regular array的测试却得出了相反的结果,而且更加明显:Node.js所费时间超过了io.js的5倍!

I must say that I'm quite disturbed by how much performance can differ. For such a mature product, the V8 JavaScript Engine shows way too much variation in performance between versions. I could live with that if performance would always increase with each version. But the data clearly shows that it can go either way. And that should not happen.


There is no clear winner. Sometimes Node is faster and sometimes io.js is. Also keep in mind that this test is far from anything you would do in real-life.

Even different versions of Node can behave differently in my experience. I remember that there was a regression with a development-version of Node which caused slow performance with buffers. See this issue on GitHub.

它们性能差异如此之大让我深感烦扰。作为如此成熟的产品,V8 JS引擎在不同版本上所表现的差异实在大。 我只能忍受性能伴随版本更新一直提升的产品,但上述测试数据表明性能有可能适得其反,这实在不该发生。



据我所悉,就连不同版本的Node都会有不同。曾记得一个开发版的Node在处理buffer的性能上却有下降表现,参考issue on GitHub.

This can be extremely important if you have a project with heavy CPU-use and which scales to several servers on something like AWS or Azure. You could potentially be wasting a lot of money if your application performs poorly with the version of Node/io.js that you use. You could be needing more servers than necessary because of that.

If you take only one piece of information from this article, then let it be toalways remember to test how your code performs with different versions of Node/io.js.