mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 22:16:16 +00:00

Apply strict mode to benchmark code. PR-URL: https://github.com/nodejs/node/pull/5336 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
33 lines
785 B
JavaScript
33 lines
785 B
JavaScript
'use strict';
|
|
var common = require('../common.js');
|
|
var url = require('url');
|
|
var v8 = require('v8');
|
|
|
|
var bench = common.createBenchmark(main, {
|
|
type: ['one'],
|
|
n: [1e5],
|
|
});
|
|
|
|
function main(conf) {
|
|
var type = conf.type;
|
|
var n = conf.n | 0;
|
|
|
|
var inputs = {
|
|
one: ['http://example.com/', '../../../../../etc/passwd'],
|
|
};
|
|
var input = inputs[type] || [];
|
|
|
|
// Force-optimize url.resolve() so that the benchmark doesn't get
|
|
// disrupted by the optimizer kicking in halfway through.
|
|
for (var name in inputs)
|
|
url.resolve(inputs[name][0], inputs[name][1]);
|
|
|
|
v8.setFlagsFromString('--allow_natives_syntax');
|
|
eval('%OptimizeFunctionOnNextCall(url.resolve)');
|
|
|
|
bench.start();
|
|
for (var i = 0; i < n; i += 1)
|
|
url.resolve(input[0], input[1]);
|
|
bench.end(n);
|
|
}
|