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="//jspm.io/system@0.6.js"></script>
<script>
document.getElementById('run').display = 'none';
System.import('github:codemix/fast.js')
.then(function(fast) {
window.fast = fast;
document.getElementById('run').display = '';
});
window.megafast = (function() {
/**
* Internal helper to bind a function with a known arguments contract
* to a given context
*
* fastBind(function(x) {return this[x];}, {foo: 1}, 1)
*/
function fastBind(func, thisContext, numArgs) {
switch (numArgs) {
case 3:
return function(a, b, c) {
return func.call(thisContext, a, b, c);
};
case 4:
return function(a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
}
return function() {
return func.apply(thisContext, arguments);
};
}
return {
map: function(subject, fn, thisContext) {
var length = subject.length,
result = new Array(length),
i;
if (arguments.length > 2) {
fn = fastBind(fn, thisContext, 3);
}
for (i = 0; i < length; i++) {
result[i] = fn(subject[i], i, subject);
}
return result;
},
concat: function fastConcat () {
var length = arguments.length,
arr = [],
idx = 0, //pointer to the current last index of arr
i, item, childLength, j;
for (i = 0; i < length; i++) {
item = arguments[i];
if (Array.isArray(item)) {
childLength = item.length;
arr.length += childLength;
for (j = 0; j < childLength; j++) {
arr[idx++] = item[j];
}
}
else {
arr[idx++] = item;
}
}
return arr;
},
bind: function fastBind (fn, thisContext) {
var boundLength = arguments.length - 2,
boundArgs;
if (boundLength > 0) {
boundArgs = new Array(boundLength);
for (var i = 0; i < boundLength; i++) {
boundArgs[i] = arguments[i + 2];
}
return function () {
var length = arguments.length,
args = new Array(boundLength + length),
i;
for (i = 0; i < boundLength; i++) {
args[i] = boundArgs[i];
}
for (i = 0; i < length; i++) {
args[boundLength + i] = arguments[i];
}
return fn.apply(thisContext, args);
};
}
else {
return function () {
return fn.apply(thisContext, arguments);
};
}
}
};
})();
</script>
var fastBound = fast.bind(function() {
var that = this;
}, fast);
var megaBound = megafast.bind(function() {
var that = this;
}, fast);
var nativeBound = function() {
var that = this;
}.bind(fast);
Ready to run.
Test | Ops/sec | |
---|---|---|
fast |
| ready |
new |
| ready |
Native |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.