Skip to content

Performance

KenanY edited this page Jan 12, 2013 · 26 revisions

For the graphs shown below, the margin of error used is the largest one out of the four results that the graph is showing.

All benchmarks are done in Node.js v0.8.16

Current algorithm

$ node perf/index.js
integer x 349,278 ops/sec ±0.37% (95 runs sampled)
integerArray x 335,076 ops/sec ±0.71% (98 runs sampled)
string x 50,793 ops/sec ±0.43% (97 runs sampled)
stringArray x 51,469 ops/sec ±0.47% (100 runs sampled)

Fastest is integer

Chart

The results here should be expected. Since strings need to be coerced, they take the longest.

numbers.js' algorithm

Using numbers.js' prime.simple approach yields surprising results.

$ node perf/index.js
integer x 111,429 ops/sec ±0.23% (95 runs sampled)
integerArray x 110,143 ops/sec ±0.29% (103 runs sampled)
string x 17,163 ops/sec ±0.18% (103 runs sampled)
stringArray x 4,859,686 ops/sec ±0.64% (89 runs sampled)

Fastest is stringArray

Chart

Now, the stringArray test is the fastest.

Clone this wiki locally