1'use strict';
2const common = require('../common.js');
3const fs = require('fs');
4const path = require('path');
5
6const bench = common.createBenchmark(main, {
7  value: ['@'.charCodeAt(0)],
8  n: [1e6],
9});
10
11function main({ n, value }) {
12  const aliceBuffer = fs.readFileSync(
13    path.resolve(__dirname, '../fixtures/alice.html'),
14  );
15
16  let count = 0;
17  bench.start();
18  for (let i = 0; i < n; i++) {
19    count += aliceBuffer.indexOf(value, 0, undefined);
20  }
21  bench.end(n);
22  return count;
23}
24