sindresorhus / p-map

Map over promises concurrently
MIT License
1.27k stars 58 forks source link

Question about some tests #41

Closed gfot2 closed 3 years ago

gfot2 commented 3 years ago

Hi all, and thank you very much for your effort on delivering such great tools!

I was reading the tests, in particular:

test('main', async t => {
    const end = timeSpan();
    t.deepEqual(await pMap(sharedInput, mapper), [10, 20, 30]);
    t.true(inRange(end(), {start: 290, end: 430}));
});

test('concurrency: 1', async t => {
    const end = timeSpan();
    t.deepEqual(await pMap(sharedInput, mapper, {concurrency: 1}), [10, 20, 30]);
    t.true(inRange(end(), {start: 590, end: 760}));
});

and I would like to ask how the numbers for start and stop came out? For example, for the first test I would expect the start value to be at least 300. Are those numbers dependent on the machine workload at the time the tests are running?

sindresorhus commented 3 years ago

Yeah, we give it some leeway on both sides of the expected 300ms as the exact value depends on the machine and workload.