fastobjectcopy

JavaScript performance comparison

Test case created by Josh

Info

find fastest way to reset an object to some known defaults.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
     window.defaultB = {
      a:{
       a:{
        a:1,
        b:2,
        c:3
       }
      },
      b:{
       a:1,
       b:2,
       c:3
      },
      c:{
       a:1,
       b:2,
       c:3
      },
     }
   
    window.b = JSON.parse(JSON.stringify(defaultB));
};
</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
A
window.b = {
  a:{
   a:{
    a:1,
    b:2,
    c:3
   }
  },
  b:{
   a:1,
   b:2,
   c:3
  },
  c:{
   a:1,
   b:2,
   c:3
  },
 }
pending…
B
window.b = JSON.parse(JSON.stringify(defaultB));
pending…
C
window.b = {};
window.b.a = {};
window.b.a.a = {};
window.b.a.a.a = 1;
window.b.a.a.b = 2;
window.b.a.a.c = 3;
window.b.b = {};
window.b.b.a = 1;
window.b.b.b = 2;
window.b.b.c = 3;
window.b.c = {};
window.b.c.a = 1;
window.b.c.b = 2;
window.b.c.c = 3;
pending…
D
window.b.a.a.a = 1;
window.b.a.a.b = 2;
window.b.a.a.c = 3;
window.b.b.a = 1;
window.b.b.b = 2;
window.b.b.c = 3;
window.b.c.a = 1;
window.b.c.b = 2;
window.b.c.c = 3;
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