mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
876836b135
PR-URL: https://github.com/nodejs/node/pull/18790 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
20 lines
389 B
JavaScript
20 lines
389 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1024],
|
|
type: ['buffer', 'string']
|
|
});
|
|
|
|
const zeroBuffer = Buffer.alloc(0);
|
|
const zeroString = '';
|
|
|
|
function main({ n, type }) {
|
|
const data = type === 'buffer' ? zeroBuffer : zeroString;
|
|
|
|
bench.start();
|
|
for (var i = 0; i < n * 1024; i++) Buffer.from(data);
|
|
bench.end(n);
|
|
}
|