mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
86fe5a80f3
PR-URL: https://github.com/nodejs/node/pull/49730 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
28 lines
566 B
JavaScript
28 lines
566 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],
|
|
dataSize: [
|
|
5,
|
|
30 * 1024,
|
|
],
|
|
});
|
|
|
|
let _sliceResult;
|
|
|
|
function main({ n, dataSize }) {
|
|
const data = 'a'.repeat(dataSize);
|
|
const reusableBlob = new Blob([data]);
|
|
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i)
|
|
_sliceResult = reusableBlob.slice(0, Math.floor(data.length / 2));
|
|
bench.end(n);
|
|
|
|
// Avoid V8 deadcode (elimination)
|
|
assert.ok(_sliceResult);
|
|
}
|