knockout observable vs peek (v3)

Revision 3 of this benchmark created on


Preparation HTML

<!-- This is a *view* - HTML markup that defines the appearance of your UI -->
<div id="wrapper">
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<p>Full name: <strong data-bind="text: fullName"></strong></p>
</div>


<script src="http://knockoutjs.com/downloads/knockout-3.0.0.js"></script>

Setup

// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
      var wrapper = document.getElementById('wrapper');
    
      function AppViewModel() {
        this.firstName = ko.observable("Bert");
        this.lastName = ko.observable("Bertington");
    
        this.fullName = ko.computed(function() {
          return this.firstName() + " " + this.lastName();
        }, this);
      }
    
      var app = new AppViewModel();
    
      // Activates knockout.js
      ko.applyBindings(app, wrapper);

Teardown


    var wrapper = document.getElementById('wrapper');
    ko.cleanNode(wrapper);
  

Test runner

Ready to run.

Testing in
TestOps/sec
Normal with subs
app.fullName();
ready
peek
app.fullName.peek();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.