Skip to content

Instantly share code, notes, and snippets.

@bga
Created July 2, 2010 23:17
Show Gist options
  • Save bga/462062 to your computer and use it in GitHub Desktop.
Save bga/462062 to your computer and use it in GitHub Desktop.
var i, n = 10000, m = 10;
var a = new Array(m);
var d = +new Date();
i = m; while(i--)
a[i] = '1';
console.log('fill array', new Date - d);
var d = +new Date();
i = n; while(i--)
''.concat.apply('', a);
console.log('concat', new Date - d);
var s, j;
var d = +new Date();
i = n; while(i--)
{
s = '';
j = m; while(j--)
s += '1';
}
console.log('+=', new Date - d);
/*
ff 3.6
fill array 0
concat 143
+= 516
chrome5
fill array 0
concat 169
+= 589
chrome6
fill array 0
concat 178
+= 607
opera 10.60
fill array 0
concat 78
+= 112
ie7
fill array 0
concat 450
+= 460
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment