1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/public/vendor/jquery/speed/slice.vs.concat.html
2014-04-22 18:10:41 +03:00

47 lines
868 B
HTML

<script type="text/javascript">
(function(){
// Conclusions:
// slice() is a little faster than concat() except on Chrome
// This clone() is slower on FF & IE but takes 50% on Safari & Chrome
var SIZE = 1e4,
LOOPS = 500;
var arr = new Array(SIZE);
for ( var i=arr.length-1; i >= 0; --i )
arr[i] = 0;
var t = new Date;
for ( i=0; i < LOOPS; i++ )
arr.slice(0);
var tslice = new Date - t;
t = new Date;
for ( i=0; i < LOOPS; i++ )
arr.concat();
var tconcat = new Date - t;
// clone() is just to see how fast built-ins are
t = new Date;
for ( i=0; i < LOOPS; i++ )
clone(arr);
var tclone = new Date - t;
alert([
'slice:'+tslice,
'concat:'+tconcat,
'clone:'+tclone
].join('\n'));
function clone(arr){
var i = arr.length,
copy = new Array(i);
while (i--)
copy[i] = arr[i];
return copy;
}
})();
</script>