belt core deep clone

JavaScript performance comparison

Revision 8 of this test case created by John Cockrell

Info

Running perf tests on Belt library deep clone functions

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//sjhcockrell.s3.amazonaws.com/downloads/belt.js"></script>

 
<script>
Benchmark.prototype.setup = function() {
        var
        x = {
            a: [1,2,3],
            b: {
                one: "one",
                two: {
                  point1: 2.1,
                  point2: 2.2,
                  point3: 2.3
                },
                three: [3.1, 3.2, 3.3, 3.4]
            },
            c: function(b) { b = 1; return b },
            d: "okay",
            e: 1
        };
   
    var con = B.getCache('global_console');
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Belt.clone
// Deep copy clone() function. 
// Includes constructors when possible.
var q = BELT.clone(x),
    q2 = BELT.clone(con);
pending…
jQuery.extend
// Deep copy extend() function.
var q = jQuery.extend(true, {}, x),
    q2 = jQuery.extend(true, {}, x);
pending…
Belt.clone_no_constructor
// Deep copy clone() function. 
// No constructors, just {}.
var q = BELT.clone_no_constructor(x),
    q2 = BELT.clone_no_constructor(con);
pending…
Belt.clone_object_create
// Deep copy clone() function. 
// Constructors using Object.create
var q = BELT.clone_object_create(x),
    q2 = BELT.clone_object_create(con);
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