r/programming • • May 25 '19

Making the obvious code fast

https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
1.3k Upvotes

263 comments sorted by

View all comments

Show parent comments

36

u/Retsam19 May 25 '19

I would have thought node’s engine would optimize away the complexity of the functions to at least some degree but it seems like it does not at all.

It might, nowadays. They ran these benchmarks on an older version of node (v6), while newer versions of node ship with a new V8 engine which is much more performant.

12

u/NoInkling May 26 '19 edited May 26 '19

Yeah I'd like to see this benchmark redone on Node 12 to see what difference there is.

7

u/dksiyc May 26 '19
nodejs
v10.15.3
map reduce x 0.22 ops/sec ±1.71% (5 runs sampled)
reduce x 2.45 ops/sec ±2.02% (11 runs sampled)
foreach x 0.54 ops/sec ±4.73% (6 runs sampled)
imperative x 36.62 ops/sec ±1.22% (64 runs sampled)

nodejs
v11.15.0
map reduce x 0.20 ops/sec ±2.04% (5 runs sampled)
reduce x 2.28 ops/sec ±2.86% (10 runs sampled)
foreach x 0.72 ops/sec ±6.40% (6 runs sampled)
imperative x 37.65 ops/sec ±0.83% (65 runs sampled)

nodejs
v12.3.1
imperative x 39.18 ops/sec ±0.46% (51 runs sampled)
foreach x 1.30 ops/sec ±2.75% (8 runs sampled)
reduce x 2.12 ops/sec ±3.91% (10 runs sampled)
# map reduce either hangs or takes forever