mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
95434fbf28
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>
23 lines
473 B
JavaScript
23 lines
473 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
size: [0, 512, 16386],
|
|
difflen: ['true', 'false'],
|
|
n: [1e6],
|
|
});
|
|
|
|
function main({ n, size, difflen }) {
|
|
const b0 = Buffer.alloc(size, 'a');
|
|
const b1 = Buffer.alloc(size + (difflen === 'true' ? 1 : 0), 'a');
|
|
|
|
if (b1.length > 0)
|
|
b1[b1.length - 1] = 'b'.charCodeAt(0);
|
|
|
|
bench.start();
|
|
for (let i = 0; i < n; i++) {
|
|
b0.equals(b1);
|
|
}
|
|
bench.end(n);
|
|
}
|