-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: avoid additional validation for Buffers
These changes result in ~50% improvement in the included benchmark. PR-URL: #10580 Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
ded1757
commit 59196af
Showing
2 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const Writable = require('stream').Writable; | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [2e6] | ||
}); | ||
|
||
function main(conf) { | ||
const n = +conf.n; | ||
const b = Buffer.allocUnsafe(1024); | ||
const s = new Writable(); | ||
s._write = function(chunk, encoding, cb) { | ||
cb(); | ||
}; | ||
|
||
bench.start(); | ||
for (var k = 0; k < n; ++k) { | ||
s.write(b); | ||
} | ||
bench.end(n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters