Try/Catch Block Loop Performance Comparison (v2)

Revision 2 of this benchmark created on


Description

Measuring the performance implications of a try/catch block used with loops.

Test runner

Ready to run.

Testing in
TestOps/sec
Plain Loop
/*
if (window.test1 !== undefined){
  window.test1 = window.test1 + 1;
} else {
  window.test1 = 0;
}
// console.log("test1="+window.test1);
*/
for(var i = 0; i < 500; i++){
    var n = 1;
}
ready
test2
try{
    for(var i = 0; i < 500; i++){
        var n = 1;
    }
}catch(e){}
ready
Try/Catch Block Inside Loop
for(var i = 0; i < 500; i++){
    try{
        var n = 1;
    }catch(e){}
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.