numberic key vs string key

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var hash1 = {};
    var hash2 = {};
    var hash3 = {};
    var hash4 = {};
    var hash5 = {};
    var hash6 = {};
    var key = "f123456";
    var okey = {
      toString: function() {
        return "f123456";
      }
    };
    try {
      var name = new Name();
    } catch (e) {}
};
</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
numberic
hash1[-23456789] = null;
pending…
string
hash2['a23456789'] = null;
pending…
string number
hash3['23456789'] = null;
pending…
var
hash4[key] = null;
pending…
Name
hash5[name] = null;
pending…
toString
hash6[okey] = null;
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