diff options
author | James M Snell <jasnell@gmail.com> | 2016-04-15 13:55:23 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-04-20 14:57:46 -0700 |
commit | cb9eff2f93731b03a7d7138eee3919243a0cfd69 (patch) | |
tree | c0ca8551cc5b929e985d39c5f7a4ba52f0871355 /benchmark | |
parent | 33c242e7e98725e9cca7914186d6ca96eb9b1035 (diff) | |
download | android-node-v8-cb9eff2f93731b03a7d7138eee3919243a0cfd69.tar.gz android-node-v8-cb9eff2f93731b03a7d7138eee3919243a0cfd69.tar.bz2 android-node-v8-cb9eff2f93731b03a7d7138eee3919243a0cfd69.zip |
benchmarks: add common.v8ForceOptimization
It's useful to be able to force optimization of a function.
Rather than duplicating the code everywhere for it, let's
make a utility available.
PR-URL: https://github.com/nodejs/node/pull/6222
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/common.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/benchmark/common.js b/benchmark/common.js index d1bc985f09..71b93d038a 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -255,3 +255,15 @@ Benchmark.prototype.getHeading = function() { }).join(','); } }; + +exports.v8ForceOptimization = function(method, ...args) { + if (typeof method !== 'function') + return; + const v8 = require('v8'); + v8.setFlagsFromString('--allow_natives_syntax'); + method.apply(null, args); + eval('%OptimizeFunctionOnNextCall(method)'); + method.apply(null, args); + return eval('%GetOptimizationStatus(method)'); +}; + |