mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
ccf05ef751
PR-URL: https://github.com/nodejs/node/pull/54310 PR-URL: https://github.com/nodejs/node/pull/54311 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
21 lines
432 B
JavaScript
21 lines
432 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
const bench = common.createBenchmark(main, {
|
|
encoding: [
|
|
'utf8', 'ascii', 'latin1',
|
|
],
|
|
len: [1, 8, 16, 32],
|
|
n: [1e6],
|
|
});
|
|
|
|
function main({ len, n, encoding }) {
|
|
const buf = Buffer.allocUnsafe(len);
|
|
const string = Buffer.from('a'.repeat(len)).toString();
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i) {
|
|
buf.write(string, 0, encoding);
|
|
}
|
|
bench.end(n);
|
|
}
|