Created
September 22, 2010 20:38
-
-
Save bga/592519 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
"use strict"; | |
(function() | |
{ | |
var _warmUp = function() | |
{ | |
var d = Date.now(); | |
while(Date.now() - d < 4000) | |
{ | |
var i = 1e6; while(i-- >= 0); | |
} | |
}; | |
var _test = function(n, a) | |
{ | |
var j = n; while(j-- >= 0) | |
{ | |
var i = a.length; while(i-- >= 0) | |
a[i] = i; | |
} | |
}; | |
_warmUp(); | |
var d = Date.now(); | |
_test(1000, new Array(1000)); | |
trace('array', Date.now() - d); | |
var d = Date.now(); | |
_test(1000, {length: 1000}); | |
trace('object', Date.now() - d); | |
})(); | |
// array 7100 | |
// object 4887 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment