We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 824e2f8 commit 9fbb8d4Copy full SHA for 9fbb8d4
1 file changed
benchmark/streams/transform-by.js
@@ -0,0 +1,23 @@
1
+'use strict';
2
+
3
+const common = require('../common');
4
+const Transform = require('stream').Transform;
5
6
+const bench = common.createBenchmark(main, {
7
+ n: [1e6]
8
+});
9
10
+function main({ n }) {
11
+ const s = Transform.by(async function*(source) {
12
+ for await (const chunk of source) {
13
+ yield chunk.toUpperCase();
14
+ }
15
+ });
16
+ s.resume();
17
18
+ bench.start();
19
+ for (var k = 0; k < n; ++k) {
20
+ s.write(String.fromCharCode(n % 64 + 64));
21
22
+ s.end(() => bench.end(n));
23
+}
0 commit comments