Try/Catch Block Performance Comparison for middleware (v15)

Revision 15 of this benchmark created on


Description

Measuring the performance implications of a try/catch block.

Setup

var res = {send:function(body){console.log(body)}}
    
    function simple(req,res){
        res.send(req);
    }
    
    function pattern(req,res){
        try {
            res.send(req.body.data);
        } catch (e) {
            res.send(500);
        }
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Plain
simple({body:{data:'test'}}, res)
ready
Try/Catch Block
pattern({body:{data:'test'}}, res)
ready
Try/Catch Block With Error
pattern(undefined, res)
ready

Revisions

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