mirror of https://github.com/nodejs/node.git
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>pull/6161/merge
parent
33c242e7e9
commit
cb9eff2f93
|
@ -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)');
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue