Try/Catch performance overhead (v17)

Revision 17 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
TestOps/sec
try/catch like func
var trycache=function(callback)
{
try
{
callback();
}
catch(e)
{}
}
var f=function() {
var s = [];
for (var i = 0; i < j; i++) s[i] = i;}

trycache(f);
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.