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>
/*just a sample function so we have something custom properties can be attached to*/
cache1 = {};
cache2 = [];
cache3 = function (){};
cache3.cache = {};
$cache4 = function(){
this.cache = {};
};
$cache4.prototype.set = function(i, val){ this.cache[i] = val; };
$cache4.prototype.get = function(i){ return this.cache[i]; };
$cache4.prototype.del = function(){ this.cache = {}; };
cache4 = new $cache4();
cache5 = (function(){
var cache = {};
return {
set: function(i, val){ cache[i] = val; },
get: function(i){ return cache[i]; },
del: function(){ cache={}; },
cache: cache
}
}());
cache6 = new function(){
this.cache = {};
return {
set: function(i, val){ this.cache[i] = val; },
get: function(i){ return this.cache[i]; },
del: function(){ this.cache={}; },
cache: this.cache
}
}();
cache7 = new function(){
var $this = this;
$this.cache = {};
return {
set: function(i, val){ $this.cache[i] = val; },
get: function(i){ return $this.cache[i]; },
del: function(){ $this.cache={}; },
cache: $this.cache
}
}();
cache8 = (function(){
var cache = {};
return {
set: function(i, val){ this.cache[i] = val; },
get: function(i){ return this.cache[i]; },
del: function(){ this.cache={}; },
cache: this.cache
}
}());
$cache9 = function $cache9(){};
$cache9.prototype.cache = {};
$cache9.prototype.set = function(i, val){ this.cache[i] = val; };
$cache9.prototype.get = function(i){ return this.cache[i]; };
$cache9.prototype.del = function(){ this.cache={}; };
cache9 = new $cache9();
cache10 = new function(){
this.set = function(key, val){ this[key] = val; };
this.get = function(key){ return this[key]; };
this.del = function(){ };
return this;
}();
cache11 = function(){};
cache11.set = function(key, val){ this[key] = val; };
cache11.get = function(key){ return this[key]; };
cache11.del = function(){ };
cache12 = new function(cache){
this.cache = cache;
this.set = function(i, val){ this.cache[i] = val; };
this.get = function(i){ return this.cache[i]; };
this.del = function(){ this.cache={}; };
return this;
}({});
cache13 = new function(){
this.cache = {};
this.set = function(i, val){ this.cache[i] = val; };
this.get = function(i){ return this.cache[i]; };
this.del = function(){ this.cache={}; };
return this;
};
cache14 = new function(){
this.set = function(i, val){ cache1[i] = val; };
this.get = function(i){ return cache1[i]; };
this.del = function(){ cache1 = {}; };
return this;
};
setter = function(i, val){ cache1[i] = val; };
getter = function(i){ return cache1[i]; };
delete1 = function(){ cache1={}; };
setter2 = function(cache, i, val){ cache[i] = val; }; // <-- arr lookup
getter2 = function(cache, i){ return cache[i]; }; // <-- arr lookup
delete2 = function(){ cache1={}; };
setter3 = function(item, val){ item = val; }; // <-- inline cache
getter3 = function(item){ return item; }; // <-- inline cache
//delete3 = function(){ };
setter4 = function(item, val){ if(item!==val) item = val; }; // <-- lazy pattern
getter4 = function(item){ return item; };
//delete4 = function(){ };
</script>
cache1 = {};
cache2 = [];
cache3.cache = {};
cache4.del();
cache5.del();
cache6.del();
cache7.del();
cache8.del();
cache9.del();
//cache10.cache = {};
//cache11.cache = {};
cache12.del();
cache13.del();
cache14.del();
delete1();
delete2();
Ready to run.
Test | Ops/sec | |
---|---|---|
Object Array |
| ready |
Simple Array |
| ready |
Function Properties |
| ready |
Prototype |
| ready |
Module Pattern 1 |
| ready |
Module Pattern 2 |
| ready |
Module Pattern 3 |
| ready |
Module Pattern 4 |
| ready |
Prototype |
| ready |
Function Properties 2 |
| ready |
Function Properties 3 |
| ready |
Function Properties 4 |
| ready |
Function Properties > Object Array |
| ready |
Helper Functions (Values Passed) |
| ready |
Helper Functions (Array Passed) |
| ready |
Helper Functions (Property Passed +Inline Cache) |
| ready |
Helper Functions (Property Passed +Lazy Pattern) |
| ready |
Object Array Wrapped Closure |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.