Try/Catch performance overhead (v15)

Revision 15 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 j=1000;

Test runner

Ready to run.

Testing in WebKit 537.36 / undefined
TestOps/sec
control - no try/catch
var s = [];
for (var i = 0; i < j; i++) s[i] = i;
ready
try/catch inside function
try
{
var s = [];
for (var i = 0; i < j; i++) s[i] = i;
}
catch(e)
{}
ready
try/catch outside function
var f=function() {
var s = [];
for (var i = 0; i < j; i++) s[i] = i;}

try
{
f()
}
catch(e)
{}
ready

Revisions

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