objdir

JavaScript performance comparison

Revision 14 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var range = function(min, max, diff) {
        "use strict";
        var returnList = [];
        i = min;
        if (!diff) {
          diff = 1;
        }
        for (; i < max; i = i + diff) {
          returnList.push(i);
        }
        return returnList;
        },
        obj = {},
        data = range(1, 10000),
        i = 0;
    for (; i < data.length; i += 1) {
      obj[i] = i + 1;
    }
};
</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
for in
var t;
for (var a in obj) {
  t = a + "->" + obj[a];
}
pending…
for in cached
var a,t;
for (a in obj) {
  t = a + "->" + obj[a];
}
pending…
Object prototype
var t;
Object.keys(obj).forEach(function(key) {
  t = key + "->" + obj[key];
});
pending…
Object prototype with for loop
var keys = Object.keys(obj),
    len = keys.length,
    t,
    i=0;
for (; i < len; i += 1) {
  t = keys[i] + "->" + obj[keys[i]];
}
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