0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/buffers/buffer-indexof-number.js
Brian White e0f0f2664e
buffer: use slightly faster NaN check
PR-URL: https://github.com/nodejs/node/pull/12286
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-04-14 18:01:43 -04:00

24 lines
492 B
JavaScript

'use strict';
const common = require('../common.js');
const fs = require('fs');
const path = require('path');
const bench = common.createBenchmark(main, {
value: ['@'.charCodeAt(0)],
n: [1e7]
});
function main(conf) {
const n = +conf.n;
const search = +conf.value;
const aliceBuffer = fs.readFileSync(
path.resolve(__dirname, '../fixtures/alice.html')
);
bench.start();
for (var i = 0; i < n; i++) {
aliceBuffer.indexOf(search, 0, undefined);
}
bench.end(n);
}