Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-12-10 01:26:24 +0300
committerBen Noordhuis <info@bnoordhuis.nl>2014-12-20 01:10:31 +0300
commit1a63b45a2a32b3df60118518bf22171b81b89ba9 (patch)
treed801372e45a4804fab070ee3674c91bc60ddc09b /benchmark/url
parentc4a308d223e2796b6af77213abb8f3dd5e31e67f (diff)
benchmark: pre-optimize url.parse() before start
Force V8 to optimize url.parse() before starting the actual benchmark. Tries to minimize variance between successive runs caused by the optimizer kicking in at different points. It does not seem to have much impact, CPU times are roughly the same before and afterwards; url.parse() quickly plateaus at a local optimum where most time is spent in V8 builtins, notably Runtime_StringSplit() and Object::GetElementWithReceiver() calls originating from deps/v8/src/uri.js, with no recurring optimize/deoptimize cycles that I could spot. Still, I don't see any downsides to pre-optimizing the function being benchmarked so in it goes. PR-URL: https://github.com/iojs/io.js/pull/132 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'benchmark/url')
-rw-r--r--benchmark/url/url.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/benchmark/url/url.js b/benchmark/url/url.js
index 7939a295317..ffa47c4ccd6 100644
--- a/benchmark/url/url.js
+++ b/benchmark/url/url.js
@@ -1,5 +1,6 @@
var common = require('../common.js');
var url = require('url');
+var v8 = require('v8');
var bench = common.createBenchmark(main, {
type: 'one two three four five six'.split(' '),
@@ -20,6 +21,14 @@ function main(conf) {
};
var input = inputs[type] || '';
+ // Force-optimize url.parse() so that the benchmark doesn't get
+ // disrupted by the optimizer kicking in halfway through.
+ for (var name in inputs)
+ url.parse(inputs[name]);
+
+ v8.setFlagsFromString('--allow_natives_syntax');
+ eval('%OptimizeFunctionOnNextCall(url.parse)');
+
bench.start();
for (var i = 0; i < n; i += 1)
url.parse(input);