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
function vargs(fn) {
var slice = Array.prototype.slice,
paramsCount = fn.length
return function () {
var argsCount = arguments.length,
lastArg = arguments[argsCount - 1],
args
if (argsCount < paramsCount && typeof lastArg === 'function') {
args = slice.call(arguments, 0, argsCount - 1)
for (var i = paramsCount - argsCount; i; i -= 1)
args.push(undefined)
args.push(lastArg)
return fn.apply(this, args)
}
return fn.apply(this, arguments)
}
}
var add1 = vargs(function (a, b, options, callback) {
options = options || {}
var sum = a + b
return callback(null, sum)
})
var add2 = function (a, b, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
var sum = a + b
return callback(null, sum)
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Arguments normalization decorator |
| ready |
Inline arguments normalization |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.