Closed stefanpenner closed 9 years ago
(n=100000) hand-rolled baseline x 2,196,801 ops/sec ±3.47% (79 runs sampled) (n=100000) native x 47.06 ops/sec ±4.48% (51 runs sampled) (n=100000) _.map/filter x 136,975 ops/sec ±4.23% (80 runs sampled) (n=100000) t.map/filter+transduce x 410,112 ops/sec ±4.12% (81 runs sampled)
confuses me...
Not sure what you mean by "hand-rolled isn't that much faster"? Looking at the largest array, looks like it's quite a bit faster. I also think these benchmarks are only appropriate when the size of the array is at least 1000 or so, otherwise you're probably in the territory of testing tiny specific details of how the JIT works.
(n=1000) hand-rolled baseline x 564,258 ops/sec ±3.82% (83 runs sampled) (n=1000) native x 6,173 ops/sec ±4.23% (80 runs sampled) (n=1000) _.map/filter x 143,803 ops/sec ±3.56% (82 runs sampled) (n=1000) t.map/filter+transduce x 408,646 ops/sec ±3.56% (79 runs sampled)
(n=10000) hand-rolled baseline x 569,765 ops/sec ±3.23% (80 runs sampled) (n=10000) native x 641 ops/sec ±3.85% (80 runs sampled) (n=10000) _.map/filter x 141,814 ops/sec ±3.71% (84 runs sampled) (n=10000) t.map/filter+transduce x 423,888 ops/sec ±3.85% (82 runs sampled)
some of the intermediate tests don't have the ratio I expected. Likely warrants further investigation.
Oh, now I see what you mean in the other comment above. Transducers are pretty close all up until the largest array. That is good; the way transducers are structured should make it easy for the engine to inline almost all of the work (it's just a few tiny function calls per item). At least that's why I assume it performs so well.
Not sure about that largest array case though, and why hand-rolled jumps up so much.
Agreed about benchmarks as mega-trolling, but it is good to demonstrate if done correctly. Insights gained should be roughly interpreted at best.
some of the intermediate tests don't have the ratio I expected. Likely warrants further investigation.
I would guess that those are the correct ones, and we need to look into why hand-rolled jumps up so much with the largest array. These should be highly optimized by the engine, so not surprised if they perform so well... but yeah, I'll look into all of this more.
I also think these benchmarks are only appropriate when the size of the array is at least 1000 or so, otherwise you're probably in the territory of testing tiny specific details of how the JIT works.
Maybe, but many app scenarios are compositions of many different array compositions processing small N. So although I wouldn't want to sacrifice large N throughput, I would still minimize overhead for small N
@jlongster thanks :)
@stefanpenner np! this is the rendered graph of that benchmark now: http://jlongster.com/s/trans-bench2.png. Working on running it in other engines than node (transducers do win the most in v8)
someone should review as benchmarks are always mega trolling, but hand-rolled isn't that much faster then transducers. (in this case)
output
lodash master (as it has lazy support that isn't released yet)