Created
December 8, 2012 20:58
-
-
Save Constellation/4241908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
t2 is very slow. Because t2 becomes sparse and GetElementIC cannot apply it.