trycatch

JavaScript performance comparison

Test case created

Info

checking the performance of try/catch statements versus conventional error checking

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var num = 0;
    var increment = function(){
       num++;
    };
};
</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
try {
  console.log(num);
  increment();
}
catch (e) {
  console.log(e);
}
pending…
Check if Exists
if (typeof num !== "undefined" && num !== null) {
  console.log(num);
  increment();
}
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:

0 comments

Add a comment