Catch exception

JavaScript performance comparison

Test case created by Vladimir Kuznetsov

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function getProperty(obj, prop) {
    return prop.split('.')
      .reduce(function(m, i) {
        return m && typeof m == 'object' ? m[i] : null;
      }, obj);
  }
  
  var obj = {
    a: {
      b: {
        c: 42
      }
    }
  };

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Use function to get property
var result;
result = getProperty(obj, 'a.x.y');
pending…
Use try/catch block to suppress errors
var result;
try {
  result = obj.a.x.y;
} catch (e) {}
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.

0 Comments