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>
"use strict";
var wrapFunction = function( fn, context ) {
return function() {
var args = new Array( arguments.length + 2 );
args[0] = "arg 1";
args[1] = "arg 2";
var n = 2;
for ( var i = 0; i < arguments.length; n++, i++ )
args[n] = arguments[i];
return fn.apply( context, args );
};
};
var wrapFunctionNoArgMod = function( fn, context ) {
return function() {
return fn.apply( context, arguments );
};
};
// Test object
var obj = {
prop: "prop",
test: function( a, b, c ) {
var d = a + b + c + this.prop;
return d; // just to do something
}
};
// Using custom method
var wrapped = wrapFunction( obj.test, obj );
// wrapped("a");
// Using native bind
var bound = obj.test.bind( obj, "arg 1", "arg 2" );
// bound("a");
var wrapNoArgMod = wrapFunctionNoArgMod( obj.test, obj );
var boundNoArgMod = obj.test.bind( obj );
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Calling wrapped |
| ready |
Calling bound |
| ready |
wrapping and calling |
| ready |
binding and calling |
| ready |
Direct call |
| ready |
Call wrapNoArgMod |
| ready |
Call boundNoArgMod |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.