diff options
Diffstat (limited to 'speed/slice.vs.concat.html')
-rw-r--r-- | speed/slice.vs.concat.html | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/speed/slice.vs.concat.html b/speed/slice.vs.concat.html index 949c5f962..a5372a690 100644 --- a/speed/slice.vs.concat.html +++ b/speed/slice.vs.concat.html @@ -6,42 +6,42 @@ var SIZE = 1e4, LOOPS = 500; - + var arr = new Array(SIZE); - for ( var i=arr.length-1; i >= 0; --i ) + for ( var i = arr.length - 1; i >= 0; --i ) arr[i] = 0; var t = new Date; - for ( i=0; i < LOOPS; i++ ) + for ( i = 0; i < LOOPS; i++ ) arr.slice(0); var tslice = new Date - t; - + t = new Date; - for ( i=0; i < LOOPS; i++ ) + 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++ ) + 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>
\ No newline at end of file +</script> |