Try/Catch

JavaScript performance comparison

Test case created by Micheil

Preparation code

<script>
  function a() {
   try {
    return "foo";
   } catch (e) {
    return e;
   }
  }
 
  function b() {
   return "foo";
  }
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Try/Catch
a();
pending…
No Try/Catch
b();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Oria commented :

Example is not accurate - when using larger peace of code, the try-catch overhead is minimized. I'll create more tests

Add a comment