Try/Catch performance overhead (v29)

Revision 29 of this benchmark created on


Description

Using try/catch inside of functions that allocate lots of variables introduces significant overhead. See this discussion related to node.js https://groups.google.com/forum/#!topic/nodejs-dev/E-Re9KDDo5w

Interestingly, other js engines don't have this overhead. All test runs have pretty uniform performance. But they are also significantly slower than the v8 control case.

Setup

var test = {
      iterations: 1000,
      randomKey: true
    };

Test runner

Ready to run.

Testing in
TestOps/sec
control - no try/catch
if(test.randomKey) {

for(var i = 0; i < test.iterations; i++) {
  test["blah" + i] = i;
}

}
ready
try/catch
try {

for(var i = 0; i < test.iterations; i++) {
  test["blah" + i] = i;
}

}
catch(e) {}
ready

Revisions

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