Hi! Dimitri, poor English here, too ;-)
One point: Your for loop presumes that never a player is removed of the logic. Take care of this, and array with number indexes vs array or objects as dictionaries Then, second point, to clarify the above warning: Node.js uses Google V8 engine, then, check these links: http://www.html5rocks.com/en/tutorials/speed/v8/ http://v8-io12.appspot.com/#1 More about objects vs arrays http://coding.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/ Angel "Java" Lopez @ajlopez On Sat, Apr 27, 2013 at 7:52 AM, Dimitri Bouriez < [email protected]> wrote: > Hi all, > > I'm working on a multiplayer game where each player's informations is > stored in an array of objects indexed by the id of the players. All > treatments are done on the players by functions. > > That is to create an object with player informations and functions will > degrade performance ? I have nearly a thousand players connected > simultaneously, whereby the features to be created 1000 times. Or store the > information in an array is the fastest way with functions outside ? > > Here's how I build the array of players (in a loop): > > var playerId = rows[i].playerId; > player[playerId] = {}; > player[playerId].name = rows[i].name; > player[playerId].email = rows[i].email; > player[playerId].money = rows[i].money; > > > > I know that the fastest way to iterate through the array of objects is a > way to do like this: > > for(var i = 1, len = player.length; i < len; i++) { > console.log(player[i]); > } > > > Thank you, and sorry for my poor English, i'm french. > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
