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
Just a quick test for Array.prototype.slice after learning it's very slow. Testing the idea put forth here: http://bonsaiden.github.com/JavaScript-Garden/
<script>
var my_data=["one", 1, 3, "two", { foo : "bar" }], item=null;
function check_slice( data ) {
var args = Array.prototype.slice.call(arguments,0);
if( args[4] && args[4].foo && args[4].foo == "bar") {
item=args[4];
}
}
function check_loop() {
var a=arguments, args=[];
for(var i=0; i<a.length; i++) {
args.push( a[i] );
}
if( args[4] && args[4].foo && args[4].foo == "bar") {
item=args[4];
}
}
function check_array_instance() {
var args = [].slice.call(arguments,0);
if( args[4] && args[4].foo && args[4].foo == "bar") {
item=args[4];
}
}
function loop_decrement() {
var _args=arguments, args=[], arg, i=_args.length-1;
while( arg=_args[i] ) {
args.shift( arg );
i-=1;
}
if( args[4] && args[4].foo && args[4].foo == "bar") {
item=args[4];
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Array.prototype.slice Bake Off |
| ready |
Simple Loop Bake Off |
| ready |
Array Instance |
| ready |
Loop Decrement |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.