Skip to content

Comparison candle vs cb vs future vs addTimeout

AlexeyKupershtokh edited this page Nov 12, 2012 · 4 revisions
candle cb future addTimeout
support timeouts + + + +
how it works add `callback` (along with a timeout obj) to an internal structure of a `candle` instance and assign an id to it wraps `callback` into a closure with `count`, `once`, `timedout`, `errback` and `tid` variables creates a Future object wrap `callback` into a closure with `startDate` and `timeoutId` variables
mode (on or once) `once` `on` and `once` (.once) `on` (.whenever & .deliver) and `once` (.when & .fullfill) `on`
can call `callback` after time out - - depends -
can clear or prolongate timeout + prolongate only +, auto prolongation on delivery -
can pass arguments on regular calling + + + -
explicit error handling - + + +
configurable error handler call + (pass `new Timeout()` as a first arg by default) - (always passes `new TimeoutError()` as a first arg) - (always passes `new FutureTimeoutException()` as a first arg) - (always passes `new TimeoutError()` as a first arg)
can forcibly free `callback` before ... + - - -
syntax sugar procedural style in handling `callback`s ok ok ok
network friendly + provides an id that can be passed forth and back over network - - -
Performance on Samsung R560, Intel(R) Core(TM)2 Duo P7350 @ 2.00GHz, 6GB DDR3 RAM, Xubuntu 12.10 64 bit
1000*add + 1000*resolve 1782 ops/sec 275 ops/sec 53 ops/sec N/A
1000*add + 1000*setTimeout + 1000*resolve 394 ops/sec 143 ops/sec 44 ops/sec 147 ops/sec
1000*(add + setTimeout) + 1000*timeout 296 ops/sec 41 ops/sec 27 ops/sec 9 ops/sec
Performance on Intel(R) Core(TM)2 Duo E8500 @ 3.16GHz, 6GB DDR2 RAM, Ubuntu 11.04 32 bit
1000*add + 1000*resolve 2121 ops/sec 417 ops/sec 85 ops/sec N/A
1000*add + 1000*setTimeout + 1000*resolve 568 ops/sec 208 ops/sec 74 ops/sec 239 ops/sec
1000*(add + setTimeout) + 1000*timeout 389 ops/sec 61 ops/sec 42 ops/sec 14 ops/sec
Clone this wiki locally