2017-04-08 14:20:40 +08:00
|
|
|
'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]
|
|
|
|
});
|
|
|
|
|
2017-12-30 10:59:57 +08:00
|
|
|
function main({ n, value }) {
|
2017-04-08 14:20:40 +08:00
|
|
|
const aliceBuffer = fs.readFileSync(
|
|
|
|
path.resolve(__dirname, '../fixtures/alice.html')
|
|
|
|
);
|
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < n; i++) {
|
2017-12-30 10:59:57 +08:00
|
|
|
aliceBuffer.indexOf(value, 0, undefined);
|
2017-04-08 14:20:40 +08:00
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|