gerich-home / it-depends

Lightweight dependency tracking library for JavaScript
http://it-depends-js.github.io/
Other
1 stars 2 forks source link

Per scenario performance comparison tests #64

Open gerich-home opened 8 years ago

gerich-home commented 8 years ago

There should be an ability to compare performance of certain scenarios (not versus KnockoutJS) For example I know at least 2 tests I want to write that way.

Given the following definitions:

var x = [];
for (var j = 0; j < dependenciesCount; j++) {
    x.push(itDepends.value(-1));
}

var a = itDepends.computed(function() {
    var z = 0;
    for (var j = 0; j < dependenciesCount; j++) {
        z += x[j]();
    }
    return z;
});

var b = itDepends.value(true);

var c = itDepends.computed(function() {
    return b() ? a() : 0;
});

the scenario:

itDepends.bulkChange(function() {
    c.onChange(function() {});
    b.write(false);
});

should work faster than scenario with approximately the same performance as in the following scenario (see #68):

c.onChange(function() {});
b.write(false);

Given the following definitions:

var x = [];
for (var j = 0; j < dependenciesCount; j++) {
    x.push(itDepends.value(-1));
}

var a = itDepends.computed(function() {
    var z = 0;
    for (var j = 0; j < dependenciesCount; j++) {
        z += x[j]();
    }
    return z;
});

var b = itDepends.value(6);
var c = itDepends.value(10);

var d = itDepends.computed(function() {
    return b() * c() === 60 ? a() : 0;
});

var s = d.onChange(function() {});

the scenario:

itDepends.bulkChange(function() {
    b.write(4);
    c.write(15);
});

should work faster than scenario:

b.write(4);
c.write(15);