-
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.
buffer: improve toJSON() performance
PR-URL: #10895 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michal Zasso <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
b3a8e95
commit 22c25de
Showing
2 changed files
with
26 additions
and
4 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,18 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e4], | ||
len: [0, 10, 256, 4 * 1024] | ||
}); | ||
|
||
function main(conf) { | ||
var n = +conf.n; | ||
var buf = Buffer.allocUnsafe(+conf.len); | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; ++i) | ||
buf.toJSON(); | ||
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