Pages
Categories
Archives
JsTweeterManiac
- first time was on conference using skype call(toll free number). Skype is really great! 1 month ago
- RT @creationix: Connect app on quad-core machine over a real network connection. 35231.05 Reqs/sec http://bit.ly/aCWnd5 #nodejs #connect 2 months ago
- some provelinks #V8 vs #php http://ow.ly/1Xbg4 vs #ruby http://ow.ly/1Xbhl vs #Perl http://ow.ly/1Xbii vs #python http://ow.ly/1Xbjk 2 months ago
- http://ow.ly/1X9Z8 about #nodejs: "It is much faster than Ruby, Python, or Perl." really??? 2 months ago
- dyuproject(openID+oAuth) http://bit.ly/cfLC1b + facebook-java-api http://bit.ly/CnjrW + native google login. 3 months ago
- Strange, but there are so many Java libs are not created yet. I need openID + oAuth(twitter) + Facebook connect. 3 months ago
- Who will come to chatroulet next to perverts? - Salesmans http://bit.ly/d6HWS1 Shit! 3 months ago
- backend development excites much more than frontend. Frontend is kind of a job. And job is boring:).... Just kidding. 3 months ago
- The Big Bang Theory: Everybody want to be Sheldon, Nobody wanna be Leonard:) 4 months ago
- Proud of myself. I have found bug in Spring framework. http://bit.ly/96Xglh 4 months ago
-
RSS Links
-
Meta
Javascript performance. Array vs Object.
Big JavaScript application needs big storage. JS gives us 2 options Array and Object. I have tested following cases:
I have tested this in following browsers:
I want to point out that i am not comparing browsers. I am comparing two methods of storing data in JavaScript.
I have checked perfomance of following pices of code:
writing [ ]
// initialization var r=[]; //code to evaluate for (i=0;i<10000;i++){ this.r[i]=7; }writing {}
// initialization var r={}; //code to evaluate for (i=0;i<10000;i++){ this.r[i]=7; }writing [ ] randomly
// initialization var r=[]; //code to evaluate for (i=0;i<10000;i++){ this.r[Math.floor(Math.random(1000))]=7; }writing { } randomly
// initialization var r={}; //code to evaluate for (i=0;i<10000;i++){ this.r[Math.floor(Math.random(1000))]=7; }Here are results in ms:
Ok the result shows us that the perfomance of Array and Object as storage is almost equal.
So semantically i think it is wise to use array for unordered information and object for mapping.