ko.viewmodel vs ko.mapping vs knockout.wrap

JavaScript performance comparison

Revision 24 of this test case created

Info

Performance comparison between the knockout mapping plugins ko.viewmodel and ko.mapping and knockout.wrap

Preparation code

<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout.mapping/2.3.5/knockout.mapping.js"></script>
<script src="http://coderenaissance.github.com/knockout.viewmodel/knockout.viewmodel.min.js"></script>
<script src="https://rawgit.com/arj03/knockout.wrap/master/knockout.wrap.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var numberOfArrayRecords = 100,
      viewmodel = null,
      model = {
        items: []
      };
   
    for (var x = 0; x < numberOfArrayRecords; x++) {
      model.items.push({
        string: "Test",
        number: 4,
        anotherObject: {
          items: [{
            id: 4,
            name: "Test"
          }, {
            id: 7,
            name: "Test2"
          }]
        }
      });
   
    }
};
</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
ko.mapping
viewmodel = ko.mapping.fromJS(model);
pending…
ko.viewmodel
viewmodel = ko.viewmodel.fromModel(model);
pending…
knockout.wrap
viewmodel = ko.wrap.fromJS(model);
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