Browse Source

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>
process-exit-stdio-flushing
James M Snell 9 years ago
parent
commit
cb9eff2f93
  1. 12
      benchmark/common.js

12
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)');
};

Loading…
Cancel
Save