Knockout Secure Binding (master)

JavaScript performance comparison

Test case created by Brian M Hunt


Compare performance of Knockout Secure Binding (master) to Knockout regular bindings

Preparation code

<script src=""></script>
<script src=""></script>
<script src=""></script>

Benchmark.prototype.setup = function() {
    var original_binder, ksb_options, ksb_binder, context, protohtml, protoref;
    original_binder = ko.bindingProvider.instance;
    ksb_options = {
        attribute: "data-bind",
        globals: {
          b: ko.observable(true)
    ksb_binder = new ko.secureBindingsProvider(ksb_options);
    context = {
        a: ko.observable("var a"),
        c: ko.observableArray([1, 2, 3, 4, 5]),
        d: function () { return [function() { return 'dv' }] },
    // access a global from Knockout proper
    window.b = ko.observable(true);
    protohtml = "<div>" +
       "<div data-bind='text: a'></div>" +
       "<div data-bind='if: b, css: { blue: a, white: a + b }'>" +
       "Something</div>" +
       "<ul data-bind='foreach: c'><li data-bind='text: $data'></li></ul>" +
       "<span data-bind='text: d()[0]()'></span>" +

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
protoref = $(protohtml);
ko.bindingProvider.instance = original_binder;
ko.applyBindings(context, protoref.get(0));
protoref = $(protohtml);
ko.bindingProvider.instance = ksb_binder;
ko.applyBindings(context, protoref.get(0));

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment