Sonia
Sonia

Reputation: 1054

Are jsPerf.com Chrome results reliable for node.js Benchmark?

I was wondering what you would think about using jsperf.com Chrome test results as a benchmark for node.js performance since they are both using V8 engine.

Upvotes: 6

Views: 1679

Answers (3)

weemonger
weemonger

Reputation: 156

I think you have to consider the different versions of v8, which are used by chrome/ium and node.js.

  1. Get the version of v8 of your current node installation:
    npm --versions list the versions of the node ecosystem, include the version of v8:

    weemonger@awesomeLinuxDistro:~$ npm --versions
    { npm: '2.11.3',
    http_parser: '2.3',
    modules: '14',
    node: '0.12.7', openssl: '1.0.1p',
    uv: '1.6.1',
    v8: '3.28.71.19',
    zlib: '1.2.8' }

  2. Get version of v8 in your current chrome/chromium: Type chrome://version/ in your address bar:

    Chromium: 38.0.2092.0 (Entwickler-Build 282911)
    Betriebssystem: Windows (not so awesome OS)
    Blink: 537.36 (@178012)
    JavaScript: V8 3.28.21
    Flash: 20,0,0,235
    User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2092.0 Safari/537.36
    ...

Kudos to bentinata for the comment.


But the safer approach is to benchmark in your specific environment (see John-David Daltons answer).


Not so nice (old) ways to get the version of v8

  • node.js

    node -e "console.log(process.versions.v8)"
    (https://stackoverflow.com/a/10264593/3346021)

  • chrome / chromium
    See Ariya Hidayats Blog to determine the version of v8 used by chrome/ium.

    First, look at the releases branches of Chromium Subversion repository, conveniently browseable at src.chromium.org/viewvc/chrome/releases.
    Now it’s a matter of checking the right version. At the moment of this writing, my Google Chrome says its at version 17.0.963.46.
    When viewing the file 17.0.963.46/DEPS (used by Gyp, the build system), you’ll find the link to the right version of V8, i.e. v8.googlecode.com/svn/branches/3.7 revision 10521.
    This can be cross-referenced in V8 repository: branches/3.7&start=10521.

Upvotes: 1

Alex Rudenko
Alex Rudenko

Reputation: 2076

I have created a tool that helps me to fetch and run tests from jsperf.com: https://github.com/OrKoN/jsperf

For example:

jsperf get replace-vs-split-join-vs-replaceall 67
jsperf run replace-vs-split-join-vs-replaceall 67

67 is the revision number here. The result is like this:

enter image description here

Upvotes: 1

John-David Dalton
John-David Dalton

Reputation: 24163

You can use Benchmark.js instead. It's what powers jsPerf and works in Node.js as well.

Upvotes: 11

Related Questions