一些当前 Node.js 中最流行 ES6 特性的 benchmark (V8 / Chakra)
生活随笔
收集整理的这篇文章主要介绍了
一些当前 Node.js 中最流行 ES6 特性的 benchmark (V8 / Chakra)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
前言
项目 github 地址:https://github.com/DavidCai1993/ES6-benchmark
如果有想要增加的特性 benchmark ,欢迎更新benchmarks/ ,然后 PR 。
环境
CPU: Intel Core(TM) i5-2410M 2.30GHz
Memory: 8GB 1600 MHz DDR3
Node.js: 5.9.0 / Node-chakracore 6.0.0-pre5
大致结论
许多情况下: V8 ES5 >> Chakra ES6 > Chakra ES5 > V8 ES6
Chakra 下的 ES6 特性表现相对更好。
Benchmark
concat-strings.js
V8: template string vs use +14,643,602 op/s » ${a}${b}96,959,110 op/s » a + bChakra: template string vs use +35,756,501 op/s » ${a}${b}19,995,366 op/s » a + bfor-of-for-loop.js
V8: for...of vs for loop851,761 op/s » for...of12,507,823 op/s » for loop, i < arr.lengthChakra: for...of vs for loop1,133,193 op/s » for...of16,715,320 op/s » for loop, i < arr.lengthmerge-objects.js
V8: merge objects669,921 op/s » Object.assign23,625,182 op/s » for...in loop and assignChakra: merge objects3,102,889 op/s » Object.assign3,744,837 op/s » for...in loop and assigndeclear-class.js
V8: declear a class118,864 op/s » Class153,662 op/s » use function and prototypeChakra: declear a class560,705 op/s » Class701,991 op/s » use function and prototyperepeat-string.js
V8: string.repeat() vs use +8,828,842 op/s » string.repeat()107,824,137 op/s » use +Chakra: string.repeat() vs use +13,022,259 op/s » string.repeat()3,328,631 op/s » use +array-like-to-array.js
V8: array like object to array1,302,649 op/s » Array.from540,458 op/s » Array.prototype.slice.callChakra: array like object to array1,864,649 op/s » Array.from2,537,458 op/s » Array.prototype.slice.callpromise-bluebird.js
promise vs bluebird V8:322,534 op/s » promise1,763,186 op/s » bluebirdChakra:69,534 op/s » promise178,186 op/s » bluebirdvar-let-const.js
V8: var let const134,028,614 op/s » let129,193,000 op/s » const431,460,321 op/s » varChakra: var let const156,028,614 op/s » let170,193,000 op/s » const150,460,321 op/s » varstring-start-with.js
V8: string starts with9,774,987 op/s » string.startsWith(value)74,127,611 op/s » string[0] === valueChakra: string starts with26,774,987 op/s » string.startsWith(value)47,127,611 op/s » string[0] === valuedefine-a-funciton-with-this.js
V8: define a function with inherited this59,661,143 op/s » () =>64,874,220 op/s » function statementChakra: define a function with inherited this69,661,143 op/s » () =>69,874,220 op/s » function statementparse-int.js
V8: global.parseInt() vs Number.parseInt()53,940,634 op/s » Number.parseInt()81,509,873 op/s » global.parseInt()Chakra: global.parseInt() vs Number.parseInt()16,940,634 op/s » Number.parseInt()19,509,873 op/s » global.parseInt()总结
以上是生活随笔为你收集整理的一些当前 Node.js 中最流行 ES6 特性的 benchmark (V8 / Chakra)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 史上最全JS表单验证封装类
- 下一篇: HDU1011 Starship Tro