Benchmark.js with node 6.6.0
Oh, that’s actually interesting. Looks like Object.assign has been improving in recent Node.js versions:
~# n use 5.10.1 test.js
JSON x 775 ops/sec ±4.22% (73 runs sampled)
Object assign x 621 ops/sec ±10.00% (70 runs sampled)
Fastest is JSON
~# n use 6.2.1 test.js
JSON x 744 ops/sec ±8.26% (68 runs sampled)
Object assign x 773 ops/sec ±9.23% (83 runs sampled)
Fastest is JSON,Object assign
~# n use 6.6.0 test.js
JSON x 877 ops/sec ±1.96% (81 runs sampled)
Object assign x 1,173 ops/sec ±0.73% (92 runs sampled)
Fastest is Object assign
Initially we’ve done our tests on 5.x a year ago. Anyway, Object.assign is only 30% faster, not a very big deal, and it doesn’t allow deep cloning (in case if we'll have inner objects in order info).
This may require changing your underlying data structure a little bit
Yes, internal data indexing is the only approach to speed things up which I can see here. It has its own drawbacks on our end, so we need to think about it carefully. For now we are not concerned with its current CPU cost, getAllOrders is not supposed to be called every tick.
Meanwhile, the CPU cost label for this method has been changed to HIGH.