Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools


it:nodejs:benchmark

Node.JS benchmarks

在 node.js 上使用 jsperf.com 的 suite 测出的结果

switch

switch vs object literal vs module

$ node -v
v0.10.26

$ node switch.js
switch: hit x 29,051,222 ops/sec ±1.17% (88 runs sampled)
switch: miss x 26,237,930 ops/sec ±0.91% (92 runs sampled)
switchObj: hit x 31,851,125 ops/sec ±1.09% (90 runs sampled)
switchObj: miss x 5,684,071 ops/sec ±1.48% (88 runs sampled)
if-else: hit x 46,947,496 ops/sec ±2.29% (76 runs sampled)
if-else: miss x 48,036,233 ops/sec ±1.77% (82 runs sampled)
if-return: hit x 43,832,934 ops/sec ±1.48% (78 runs sampled)
if-return: miss x 40,558,099 ops/sec ±1.95% (84 runs sampled)
if-combined-return: hit x 45,139,653 ops/sec ±1.23% (90 runs sampled)
if-combined-return: miss x 39,356,789 ops/sec ±1.38% (79 runs sampled)
Fastest is if-else: miss,if-else: hit
it/nodejs/benchmark.txt · Last modified: 2014/04/30 15:13 by admin