summaryrefslogtreecommitdiff
path: root/benchmark/streams/readable-from.js
blob: 2dcf10ffef27323bf3fb7a00fe38a413eef03edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';

const common = require('../common');
const Readable = require('stream').Readable;

const bench = common.createBenchmark(main, {
  n: [1e7],
});

async function main({ n }) {
  const arr = [];
  for (let i = 0; i < n; i++) {
    arr.push(`${i}`);
  }

  const s = new Readable.from(arr);

  bench.start();
  s.on('data', (data) => {
    // eslint-disable-next-line no-unused-expressions
    data;
  });
  s.on('close', () => {
    bench.end(n);
  });
}