Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Benchmark.Suite.options.onCycle = function(event) {
console.log(' ' + event.target);
};
Benchmark.Suite.options.onComplete = function() {
printFastest(this);
suites.shift();
if (suites.length) {
suites[0].run({async: true});
}
};
// ************************************************
// Benchmarks!
suites.push(Benchmark.Suite('dynamic dependencies').add('New', {
setup: function() {
var s = stream();
stream(function() {
return s();
});
},
fn: function() {
s(12);
},
}).add('Old', {
setup: function() {
var s = oldStream();
oldStream(function() {
return s();
});
},
setup: function() {
var flyd = global.flyd;
var stream = global.flyd.stream;
function f(x) { return x; }
var s1 = stream();
var s2 = s1.map(f);
var s3 = s2.map(f);
var s4 = s3.map(f);
var s5 = s4.map(f);
},
fn: function() {
s1(12);
},
}));
suites.push(Benchmark.Suite('dynamic dependency graph').add('New', {
setup: function() {
var s1 = stream();
var s2 = stream(function() {
s1(); s1();
});
var s3 = stream(function() {
s1(); s2(); s1();
});
var s4 = stream(function() {
s1(); s2(); s3(); s1(); s3();
});
stream(function() {
s3(); s2(); s1(); s3(); s4();
});
},
fn: function() {
fn: function() {
s(12);
},
}).add('Old', {
setup: function() {
var s = oldStream();
oldStream([s], function() {
return s();
});
},
fn: function() {
s(12);
},
}));
suites.push(Benchmark.Suite('map').add('First', {
setup: function() {
var flyd = global.flyd;
var stream = global.flyd.stream;
function f(x) { return x; }
var s1 = stream();
var s2 = s1.map(f);
var s3 = s2.map(f);
var s4 = s3.map(f);
var s5 = s4.map(f);
},
fn: function() {
s1(12);
},
}).add('Second', {
setup: function() {
var flyd = global.flyd;
fn: function() {
s(12);
},
}).add('Old', {
setup: function() {
var s = oldStream();
oldStream(function() {
return s();
});
},
fn: function() {
s(12);
},
}));
suites.push(Benchmark.Suite('static dependencies').add('New', {
setup: function() {
var s = stream();
stream([s], function() {
return s();
});
},
fn: function() {
s(12);
},
}).add('Old', {
setup: function() {
var s = oldStream();
oldStream([s], function() {
return s();
});
},