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
var array=["foo","bar","baz","lorem","ipsum","lol","cat"];
var func=function(){2+2};
Array.prototype.forEach2=function(a){
var l=this.length;
for(var i=0;i<l;i++)a(this[i],i)
}
Array.prototype.map2=function(a){
var l=this.length;
var array=new Array(l),i=0;
for(;i<l;i++){array[i]=a(this[i],i)}
return array;
}
var setPrototypeOf = Object.setPrototypeOf || function(o, p){
o.__proto__ = p;
return o;
};
var TrueCustomArray = function () {
var array = new (Function.prototype.bind.apply(Array, [null].concat([].slice.call(arguments))));
setPrototypeOf(array, this.__proto__);
return array;
};
TrueCustomArray.prototype = Object.create(Array.prototype, { constructor: { value: TrueCustomArray } });
TrueCustomArray.prototype.append = function(var_args) {
var_args = this.concat.apply([], arguments);
this.push.apply(this, var_args);
return this;
};
TrueCustomArray.prototype.prepend = function(var_args) {
var_args = this.concat.apply([], arguments);
this.unshift.apply(this, var_args);
return this;
};
["concat", "reverse", "slice", "splice", "sort", "filter", "map"].forEach(function(name) {
var _Array_prototype = this;
TrueCustomArray.prototype[name] = function() {
var result = _Array_prototype[name].apply(this, arguments);
setPrototypeOf(result, this.__proto__);
return result;
}
}, Array.prototype);
var customArray = new TrueCustomArray("foo","bar","baz","lorem","ipsum","lol","cat");
Ready to run.
Test | Ops/sec | |
---|---|---|
for |
| ready |
foreach |
| ready |
custom foreach |
| ready |
map |
| ready |
custom map |
| ready |
custom array for |
| ready |
custom array foreach |
| ready |
custom array custom foreach |
| ready |
custom array map |
| ready |
custom array custom map |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.