Native Try/Catch vs. Custom tryCatch (v2)

Revision 2 of this benchmark created on


Description

Investigating a means of replacing the try catch block with a suitable substitute for performance intensive operations.

Preparation HTML

<script>
var onError = null;
window.onerror = function(msg, file, line){
        var error = new Error(msg, file, line);
        if(onError){
                onError(error);
                onError = null;
        }
        return true;
};
        
function tryCatch(fn, fail){
        onError = fail;
        fn();
        onError = null;
}

function nativeTryCatch(){
        try{
                return null;
        }catch(e){
                return null;    
        }
}

function foo(){
        return null;    
}

function bar(){
        return null;    
}

function customTryCatch(){
        tryCatch(foo, bar);
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Native Try Catch
nativeTryCatch();
ready
Custom Try Catch
customTryCatch();
ready

Revisions

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