jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
<script src="https://jashkenas.github.io/underscore/underscore-min.js"></script>
<script src="https://jashkenas.github.io/backbone/backbone-min.js"></script>
Backbone.Model.prototype.matches = function(attrs) {
return _.matches(attrs)(this.attributes);
};
Backbone.Model.prototype.equal = function (attrs) {
for (var key in attrs) {
if (attrs[key] !== this.get(key)) return false;
}
return true;
};
Backbone.Collection.prototype.where = function(attrs, first) {
var matches = _.matches(attrs);
return this[first ? 'find' : 'filter'](function(model) {
return matches(model.attributes);
});
};
Backbone.Collection.prototype.count = function (attrs) {
var count = 0;
this.forEach(function (model) {
if (model.equal(attrs)) count++;
});
return count;
};
Backbone.Collection.prototype.countMatches = function (attrs) {
var count = 0;
this.forEach(function (model) {
if (model.matches(attrs)) count++;
});
return count;
};
var c = new Backbone.Collection();
for (var i = 0; i < 1000; i++) {
c.add({a: 1, b: 2, c: 3});
}
Ready to run.
Test | Ops/sec | |
---|---|---|
where().length |
| ready |
count() |
| ready |
countMatches() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.