Comment #3 on issue 2179 by [email protected]: Breakpoint of not executed function slows down javascript performance
http://code.google.com/p/v8/issues/detail?id=2179

Running the same code in d8 (slightly modified):

Debug = debug.Debug;

var BreakPointPerformance = function() {
}
BreakPointPerformance.prototype.breakFunc = function() {
   return 0;
}
BreakPointPerformance.prototype.mathFunc = function() {
   var a = Math.sqrt(Math.random());
   return a;
}
BreakPointPerformance.prototype.runLoop = function() {
   var start = new Date();
   var b = 0;
   for(var i=0;i<10000000;i++) {
       b+=this.mathFunc();
   }
   print("time: " + (new Date() - start) + "ms");
}

var p = new BreakPointPerformance();
Debug.setBreakPoint(BreakPointPerformance.prototype.breakFunc, 1, 0);
p.runLoop();

takes ~680ms (vs. ~120ms without the breakpoint). In comparison, running without crankshaft takes ~580ms, so this seems alright. Enabling debug mode triggers a recompile of all code with the non-optimizing compiler (so that loop-hoisting, inlining etc. that are not compatible with debugging are not done.)

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to