tildeio/rsvp.js — pull request #132 by stefanpenner (2013-11-23 11:47:49+00:00)
Title: Perfs

Micro benchmarks FTW.

This is a bit ongoing, but i wanted to see how much juice I could squeeze out of RSVP, fun experiment.
Interestingly accordingly to these very important micro benchmarks, RSVP is now relatively quick. In node bluebird still often takes the lead (not to mention it likely has improved memory usage over RSVP) so we have some work todo. Interestingly in the browser, RSVP now comes up ahead, putting chrome's own native DOM Promises to shame.

Node v0.10.21
```log
> promise_benchmarks@ start /Users/stefan/src/promise_benchmarks
> npm build && node index

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Promise Creation ...
- [Promise Creation] rsvp x 10,092,983 ops/sec ±1.69% (82 runs sampled)
- [Promise Creation] rsvp-2.0.4 x 509,287 ops/sec ±2.39% (75 runs sampled)
- [Promise Creation] bluebird x 5,984,504 ops/sec ±3.91% (75 runs sampled)
- [Promise Creation] when x 5,750,027 ops/sec ±2.56% (78 runs sampled)
Fastest for Promise Creation is [ 'rsvp' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Promise Rejection ...
- [Promise Rejection] rsvp x 54,269 ops/sec ±2.80% (64 runs sampled)
- [Promise Rejection] rsvp-2.0.4 x 24,179 ops/sec ±4.22% (63 runs sampled)
- [Promise Rejection] bluebird x 49,933 ops/sec ±3.87% (66 runs sampled)
- [Promise Rejection] when x 39,552 ops/sec ±5.28% (54 runs sampled)
Fastest for Promise Rejection is [ 'rsvp' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Promise Resolve: value ...
- [Promise Resolve: value] rsvp x 51,517 ops/sec ±3.24% (66 runs sampled)
- [Promise Resolve: value] rsvp-2.0.4 x 26,344 ops/sec ±2.76% (58 runs sampled)
- [Promise Resolve: value] bluebird x 53,605 ops/sec ±2.53% (66 runs sampled)
- [Promise Resolve: value] when x 38,942 ops/sec ±2.84% (60 runs sampled)
Fastest for Promise Resolve: value is [ 'bluebird', 'rsvp' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Resolve Promise: promise ...
- [Resolve Promise: promise] rsvp x 46,669 ops/sec ±1.86% (63 runs sampled)
- [Resolve Promise: promise] rsvp-2.0.4 x 2,745 ops/sec ±45.04% (15 runs sampled)
- [Resolve Promise: promise] bluebird x 44,776 ops/sec ±4.11% (64 runs sampled)
- [Resolve Promise: promise] when x 33,140 ops/sec ±4.80% (58 runs sampled)
Fastest for Resolve Promise: promise is [ 'rsvp', 'bluebird' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 1 ...
- [Then Sequence 1] rsvp x 48,692 ops/sec ±4.92% (52 runs sampled)
- [Then Sequence 1] rsvp-2.0.4 x 3,023 ops/sec ±49.28% (13 runs sampled)
- [Then Sequence 1] bluebird x 47,615 ops/sec ±5.30% (62 runs sampled)
- [Then Sequence 1] when x 38,917 ops/sec ±7.27% (60 runs sampled)
Fastest for Then Sequence 1 is [ 'rsvp', 'bluebird' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 2 ...
- [Then Sequence 2] rsvp x 43,842 ops/sec ±5.59% (60 runs sampled)
- [Then Sequence 2] rsvp-2.0.4 x 2,765 ops/sec ±38.52% (18 runs sampled)
- [Then Sequence 2] bluebird x 44,832 ops/sec ±11.06% (57 runs sampled)
- [Then Sequence 2] when x 29,350 ops/sec ±9.32% (59 runs sampled)
Fastest for Then Sequence 2 is [ 'rsvp' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 10 ...
- [Then Sequence 10] rsvp x 25,306 ops/sec ±15.29% (58 runs sampled)
- [Then Sequence 10] rsvp-2.0.4 x 6,124 ops/sec ±15.31% (53 runs sampled)
- [Then Sequence 10] bluebird x 42,072 ops/sec ±9.00% (62 runs sampled)
- [Then Sequence 10] when x 10,591 ops/sec ±18.43% (35 runs sampled)
Fastest for Then Sequence 10 is [ 'bluebird' ]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 100 ...
- [Then Sequence 100] rsvp x 5,954 ops/sec ±15.62% (53 runs sampled)
- [Then Sequence 100] rsvp-2.0.4 x 741 ops/sec ±14.78% (51 runs sampled)
- [Then Sequence 100] bluebird x 21,832 ops/sec ±11.58% (69 runs sampled)
- [Then Sequence 100] when x 880 ops/sec ±25.98% (27 runs sampled)
Fastest for Then Sequence 100 is [ 'bluebird' ]
```

Chrome 33
```log
Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Promise Creation ...
- [Promise Creation] rsvp x 8,507,313 ops/sec ±3.61% (61 runs sampled)
- [Promise Creation] rsvp-2.0.4 x 505,630 ops/sec ±3.92% (63 runs sampled)
- [Promise Creation] bluebird x 22,565 ops/sec ±3.41% (62 runs sampled)
- [Promise Creation] when x 5,996,627 ops/sec ±3.09% (66 runs sampled)
- [Promise Creation] dom x 119,991 ops/sec ±2.75% (54 runs sampled)
Fastest for Promise Creation is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Promise Rejection ...
- [Promise Rejection] rsvp x 24,669 ops/sec ±3.32% (58 runs sampled)
- [Promise Rejection] rsvp-2.0.4 x 15,485 ops/sec ±2.90% (61 runs sampled)
- [Promise Rejection] bluebird x 9,915 ops/sec ±3.22% (58 runs sampled)
- [Promise Rejection] when x 20,059 ops/sec ±4.48% (54 runs sampled)
- [Promise Rejection] dom x 14,215 ops/sec ±3.98% (58 runs sampled)
Fastest for Promise Rejection is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Promise Resolve: value ...
- [Promise Resolve: value] rsvp x 28,367 ops/sec ±4.72% (56 runs sampled)
- [Promise Resolve: value] rsvp-2.0.4 x 15,908 ops/sec ±5.69% (54 runs sampled)
- [Promise Resolve: value] bluebird x 10,806 ops/sec ±4.25% (56 runs sampled)
- [Promise Resolve: value] when x 20,627 ops/sec ±5.18% (51 runs sampled)
- [Promise Resolve: value] dom x 16,296 ops/sec ±2.83% (61 runs sampled)
Fastest for Promise Resolve: value is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Resolve Promise: promise ...
- [Resolve Promise: promise] rsvp x 25,828 ops/sec ±4.42% (55 runs sampled)
- [Resolve Promise: promise] rsvp-2.0.4 x 3,466 ops/sec ±29.87% (21 runs sampled)
- [Resolve Promise: promise] bluebird x 9,537 ops/sec ±3.73% (54 runs sampled)
- [Resolve Promise: promise] when x 19,409 ops/sec ±5.07% (51 runs sampled)
- [Resolve Promise: promise] dom x 14,223 ops/sec ±4.93% (55 runs sampled)
Fastest for Resolve Promise: promise is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Then Sequence 1 ...
- [Then Sequence 1] rsvp x 27,255 ops/sec ±4.23% (54 runs sampled)
- [Then Sequence 1] rsvp-2.0.4 x 4,286 ops/sec ±31.35% (25 runs sampled)
- [Then Sequence 1] bluebird x 10,176 ops/sec ±4.85% (57 runs sampled)
- [Then Sequence 1] when x 21,965 ops/sec ±5.40% (56 runs sampled)
- [Then Sequence 1] dom x 18,157 ops/sec ±4.18% (56 runs sampled)
Fastest for Then Sequence 1 is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Then Sequence 2 ...
- [Then Sequence 2] rsvp x 24,070 ops/sec ±4.90% (55 runs sampled)
- [Then Sequence 2] rsvp-2.0.4 x 3,835 ops/sec ±28.10% (26 runs sampled)
- [Then Sequence 2] bluebird x 6,557 ops/sec ±5.99% (55 runs sampled)
- [Then Sequence 2] when x 16,929 ops/sec ±6.36% (54 runs sampled)
- [Then Sequence 2] dom x 18,871 ops/sec ±4.17% (61 runs sampled)
Fastest for Then Sequence 2 is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Then Sequence 10 ...
- [Then Sequence 10] rsvp x 18,293 ops/sec ±8.49% (52 runs sampled)
- [Then Sequence 10] rsvp-2.0.4 x 5,440 ops/sec ±10.04% (49 runs sampled)
- [Then Sequence 10] bluebird x 1,736 ops/sec ±6.44% (43 runs sampled)
- [Then Sequence 10] when x 8,622 ops/sec ±11.88% (44 runs sampled)
- [Then Sequence 10] dom x 12,836 ops/sec ±6.27% (57 runs sampled)
Fastest for Then Sequence 10 is ["rsvp"]

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when, dom ...
Running Tests for Then Sequence 100 ...
- [Then Sequence 100] rsvp x 6,181 ops/sec ±15.32% (49 runs sampled)
- [Then Sequence 100] rsvp-2.0.4 x 654 ops/sec ±12.19% (44 runs sampled)
- [Then Sequence 100] bluebird x 197 ops/sec ±13.81% (11 runs sampled)
- [Then Sequence 100] when x 591 ops/sec ±68.42% (24 runs sampled)
- [Then Sequence 100] dom x 4,203 ops/sec ±8.90% (60 runs sampled)
Fastest for Then Sequence 100 is ["rsvp"]
```