Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created December 8, 2012 20:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Constellation/4241908 to your computer and use it in GitHub Desktop.
Save Constellation/4241908 to your computer and use it in GitHub Desktop.
function t1() {
var ary = [];
for (var i = 0; i < 10000000; ++i) {
ary[i] = i;
}
return ary;
}
function t2() {
var ary = [];
var i = 10000000;
while (i--) {
ary[i] = i;
}
return ary;
}
var now = Date.now();
t1();
print(Date.now() - now);
var now = Date.now();
t2();
print(Date.now() - now);
@Constellation
Copy link
Author

t2 is very slow. Because t2 becomes sparse and GetElementIC cannot apply it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment