GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: add stream.compose benchmark · nodejs/node@8b71fa7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/streams
    • compose.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/streams/compose.js‎

Copy file name to clipboard
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
4+
const {
5+
PassThrough,
6+
Readable,
7+
Writable,
8+
compose,
9+
} = require('node:stream');
10+
11+
const bench = common.createBenchmark(main, {
12+
n: [1e3],
13+
});
14+
15+
function main({ n }) {
16+
const cachedPassThroughs = [];
17+
const cachedReadables = [];
18+
const cachedWritables = [];
19+
20+
for (let i = 0; i < n; i++) {
21+
const numberOfPassThroughs = 100;
22+
const passThroughs = [];
23+
24+
for (let i = 0; i < numberOfPassThroughs; i++) {
25+
passThroughs.push(new PassThrough());
26+
}
27+
28+
const readable = Readable.from(['hello', 'world']);
29+
const writable = new Writable({ objectMode: true, write: (chunk, encoding, cb) => cb() });
30+
31+
cachedPassThroughs.push(passThroughs);
32+
cachedReadables.push(readable);
33+
cachedWritables.push(writable);
34+
}
35+
36+
bench.start();
37+
for (let i = 0; i < n; i++) {
38+
const composed = compose(cachedReadables[i], ...cachedPassThroughs[i], cachedWritables[i]);
39+
composed.end();
40+
}
41+
bench.end(n);
42+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.