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://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://underscorejs.org/underscore.js">
</script>
<script src="http://backbonejs.org/backbone-min.js">
</script>
<script src="https://dhruvaray.github.io/backbone-associations/backbone-associations.edge.js">
</script>
<script src="https://pauluithol.github.io/Backbone-relational/backbone-relational.js">
</script>
Benchmark.prototype.setup = function() {
var addAnimals = function(zoo, count, auto) {
var result = [];
for (var i = 0; i < count; i++) {
result.push(auto ? {species: 'species' + i} : {species: 'species' + i, livesIn:zoo });
}
return result;
};
var _populateZoo = function(zoos){
var result = [];
for (var i = 0; i < zoos; i++) {
result.push({name: i});
}
return result;
};
var setupCounties = function(countries, zoos){
var result = [];
for (var i = 0; i < countries; i++) {
result.push({name: i, zoos:_populateZoo(zoos)});
}
return result;
};
// Associated Model
var associatedModel = {};
associatedModel.Zoo = Backbone.AssociatedModel.extend({
relations: [{
type: Backbone.Many,
key: 'animals',
relatedModel: function(){return associatedModel.Animal}
}]
});
associatedModel.Animal = Backbone.AssociatedModel.extend({
relations: [{
type: Backbone.One,
key: 'livesIn',
relatedModel: function(){return associatedModel.Zoo}
}]
});
associatedModel.Country = Backbone.AssociatedModel.extend({
relations: [{
type: Backbone.Many,
key: 'zoos',
relatedModel: associatedModel.Zoo
}]
});
var relationalModel = {};
relationalModel.Animal = Backbone.RelationalModel.extend({
});
relationalModel.Zoo = Backbone.RelationalModel.extend({
relations: [{
type: Backbone.HasMany,
key: 'animals',
relatedModel: relationalModel.Animal,
reverseRelation: {
key: 'livesIn',
includeInJSON: 'id'
}
}]
});
relationalModel.Country = Backbone.RelationalModel.extend({
relations: [{
type: Backbone.HasMany,
key: 'zoos',
relatedModel: relationalModel.Zoo
}]
});
}
Ready to run.
Test | Ops/sec | |
---|---|---|
BB-Associations |
| ready |
BB-Relational |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.