mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
badba8ceb6
PR-URL: https://github.com/nodejs/node/pull/50110 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
26 lines
523 B
JavaScript
26 lines
523 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
const {
|
|
Blob,
|
|
} = require('node:buffer');
|
|
const assert = require('assert');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [50e3],
|
|
bytes: [128, 1024, 1024 ** 2],
|
|
});
|
|
|
|
let _cloneResult;
|
|
|
|
function main({ n, bytes }) {
|
|
const buff = Buffer.allocUnsafe(bytes);
|
|
const blob = new Blob(buff);
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i)
|
|
_cloneResult = structuredClone(blob);
|
|
bench.end(n);
|
|
|
|
// Avoid V8 deadcode (elimination)
|
|
assert.ok(_cloneResult);
|
|
}
|