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.pipe benchmarks · nodejs/node@be9777c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/streams
    • pipe-object-mode.js
    • pipe.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/streams/pipe-object-mode.js‎

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { Readable, Writable } = require('stream');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [5e6]
8+
});
9+
10+
function main({ n }) {
11+
const b = {};
12+
const r = new Readable({ objectMode: true });
13+
const w = new Writable({ objectMode: true });
14+
15+
var i = 0;
16+
17+
r._read = () => r.push(i++ === n ? null : b);
18+
w._write = (data, enc, cb) => cb();
19+
20+
bench.start();
21+
22+
r.pipe(w);
23+
w.on('finish', () => bench.end(n));
24+
}
Collapse file

‎benchmark/streams/pipe.js‎

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { Readable, Writable } = require('stream');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [5e6]
8+
});
9+
10+
function main({ n }) {
11+
const b = new Buffer(1024);
12+
const r = new Readable();
13+
const w = new Writable();
14+
15+
var i = 0;
16+
17+
r._read = () => r.push(i++ === n ? null : b);
18+
w._write = (data, enc, cb) => cb();
19+
20+
bench.start();
21+
22+
r.pipe(w);
23+
w.on('finish', () => bench.end(n));
24+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.