Created
September 8, 2010 10:37
-
-
Save stagas/569941 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
var myarray = [] | |
for (var i=0; i<5000000; i++) { | |
myarray.push(i) | |
} | |
var time, newTime, wlen=0, wlength=0 | |
for (var y=0; y<20; y++) { | |
time = new Date() | |
for (var x=0; x<10; x++) { | |
for (var i=0; i<myarray.length; i++) { | |
} | |
} | |
newTime = new Date() | |
wlength += newTime - time | |
time = new Date() | |
for (var x=0; x<10; x++) { | |
for (var i=0, len=myarray.length; i<len; i++) { | |
} | |
} | |
newTime = new Date() | |
wlen += newTime - time | |
} | |
console.log('With var len: ' + (wlen/20)) | |
console.log('With .length: ' + (wlength/20)) |
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
With var len: 195.65 | |
With .length: 263.75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment