mirror of https://github.com/lukechilds/node.git
Browse Source
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>v6
Brian White
8 years ago
2 changed files with 27 additions and 2 deletions
@ -0,0 +1,23 @@ |
|||
'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); |
|||
} |
Loading…
Reference in new issue