Saturday, 13 June 2020

Memory Usage Benchmarks for a Promise Cancellation Implementation

https://github.com/a-synchronous/assets/blob/master/reduce-async-iterable-promise-cancellation.pngThese benchmarks ensure that Promise cancellation does not leak memory with reduce of my libraryHere's the code being tested: javascript if (isAsyncIterable(x)) { const state = { cancel: () => {} } const cancelToken = new Promise((_, reject) => { state.cancel = reject }) const p = Promise.race([ reduceAsyncIterable(fn, x0, x), cancelToken, ]) p.cancel = () => { state.cancel(new Error('cancelled')) } return p }These benchmarks are runnable with mocha benchmarks.js at the root of the repository.

Submitted June 13, 2020 at 10:04PM by richytong

No comments:

Post a Comment