Try/Catch Block Loop Performance Comparison (v9)

Revision 9 of this benchmark created by Ashraf Samy Hegab 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
var test = function()
{
    for(var i = 0; i < 500; i++){
        var n = 1;
    }
};

test();
ready
Try/Catch Block Outside Loop
var test = function()
{
    for(var i = 0; i < 500; i++){
        var n = 1;
    }
};

try{
    test();
}catch(e){}
ready
Try/Catch Block Inside Loop
try{
    var test = function()
    {
        for(var i = 0; i < 500; i++){
            var n = 1;
        }
    };
    test();
}catch(e){}
ready

Revisions

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