Skip to content

Commit

Permalink
Test concurrency: 2
Browse files Browse the repository at this point in the history
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
  • Loading branch information
Richienb committed Nov 26, 2023
1 parent 66a76d3 commit 60419f8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test.js
Expand Up @@ -563,14 +563,22 @@ test('pMapIterable - stop on error', async t => {
t.deepEqual(output, [20]);
});

test('pMapIterable - concurrency', async t => {
test('pMapIterable - concurrency: 1', async t => {
const end = timeSpan();
t.deepEqual(await collectAsyncIterable(pMapIterable(sharedInput, mapper, {concurrency: 1})), [10, 20, 30]);

// It could've only taken this much time if each were run in series
assertInRange(t, end(), {start: 590, end: 760});
});

test('pMapIterable - concurrency: 2', async t => {
const end = timeSpan();

t.deepEqual(await collectAsyncIterable(pMapIterable(longerSharedInput, mapper, {concurrency: 2})), [10, 20, 30, 40, 50]);

assertInRange(t, end(), {start: 325, end: 375});
});

test('pMapIterable - backpressure', async t => {
let currentValue;

Expand Down

0 comments on commit 60419f8

Please sign in to comment.