mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
PR-URL: https://github.com/nodejs/node/pull/46473 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
25 lines
397 B
JavaScript
25 lines
397 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
len: [64, 1024],
|
|
n: [1e6],
|
|
});
|
|
|
|
function main({ len, n }) {
|
|
const buf = Buffer.alloc(len);
|
|
|
|
for (let i = 0; i < buf.length; i++)
|
|
buf[i] = i & 0xff;
|
|
|
|
const hex = buf.toString('hex');
|
|
|
|
bench.start();
|
|
|
|
for (let i = 0; i < n; i += 1)
|
|
Buffer.from(hex, 'hex');
|
|
|
|
bench.end(n);
|
|
}
|