0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/buffers/buffer-read-with-byteLength.js
Ruben Bridgewater bb6125bac7
benchmark: remove special test entries
This reverts commit 7cfbc9f90f.

PR-URL: https://github.com/nodejs/node/pull/31755
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-03-09 22:35:54 +01:00

31 lines
547 B
JavaScript

'use strict';
const common = require('../common.js');
const types = [
'IntBE',
'IntLE',
'UIntBE',
'UIntLE',
];
const bench = common.createBenchmark(main, {
buffer: ['fast'],
type: types,
n: [1e6],
byteLength: [1, 2, 3, 4, 5, 6]
});
function main({ n, buf, type, byteLength }) {
const buff = buf === 'fast' ?
Buffer.alloc(8) :
require('buffer').SlowBuffer(8);
const fn = `read${type}`;
buff.writeDoubleLE(0, 0);
bench.start();
for (let i = 0; i !== n; i++) {
buff[fn](0, byteLength);
}
bench.end(n);
}