compostable objects

JavaScript performance comparison

Test case created by Joshua Piccari

Info

This is probably my most poorly designed test, wish I could delete it.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var coords = Array.apply(0, Array(1e4)).map(function() {
      return new Person('Alice');
    });
   
    function Person(name) {
        this.name = name;
    }
};
</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
Control (new object)
for (var i = 0; i < coords.length; i++) {
  coords[i] = new Person('Bob');
}
pending…
Direct overwrite
for (var i = 0; i < coords.length; i++) {
  coords[i].name = 'Bob';
}
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