Skip to content

Instantly share code, notes, and snippets.

@vhf
Created November 2, 2015 12:52
Show Gist options
  • Save vhf/01c095e09accf72108a1 to your computer and use it in GitHub Desktop.
Save vhf/01c095e09accf72108a1 to your computer and use it in GitHub Desktop.
function printStatus(fn) {
var name = fn.name;
switch(%GetOptimizationStatus(fn)) {
case 1: console.log(name, ' is optimized'); break;
case 2: console.log(name, ' is not optimized'); break;
case 3: console.log(name, ' is always optimized'); break;
case 4: console.log(name, ' is never optimized'); break;
case 6: console.log(name, ' is maybe deoptimized'); break;
}
}
factorial1(100);
factorial1(100);
%OptimizeFunctionOnNextCall(factorial1);
factorial1(100);
printStatus(factorial1);
facRec2(100, 1); // I should add that facRec2(100) leads to the same perf issue
facRec2(100, 1);
%OptimizeFunctionOnNextCall(facRec2);
facRec2(100, 1);
printStatus(facRec2);
facRec3(100, 1);
facRec3(100, 1);
%OptimizeFunctionOnNextCall(facRec3);
facRec3(100, 1);
printStatus(facRec3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment