Regarding Loops
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Regarding Loops

  1. #1
    Join Date
    May 2012
    Posts
    27

    Regarding Loops

    Hi everyone

    I am writing a MMORPG server (just the server) and I am starting to focus on the "lightweight-ness" and effeciency of it.

    I am going to give an extremely short version of my question;

    I am going to use a loop to look through around 10-100 objects every minute and have an If/else statement in there. How much does a loop like this effect on my server ? It might be a silly question but I am debating on whether to create an object for every 100 instances (of clients) and then loop through 1-6 objects instead. Which one would work more effeciently ?

    if this didn't make any sense I'll try to explain it differently. Imagine around 100 clients in a map. I am trying to find 8 of those clients that are related to each other (theyre in a group/party). Would it be wisest to loop through all 100 stand alone clients to find the 8 ones, or use around 10 Objects (in this case called groups/partys) and look throughout those instead ? (each group contains 8 clients). Remember, either way this check will happen every minute or so.

    Thanks! I am curious about the responses !

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,286

    Re: Regarding Loops

    Quote Originally Posted by wutang001 View Post
    Thanks! I am curious about the responses !
    Me too. Why not test both approaches and report back?

  3. #3
    Join Date
    May 2012
    Posts
    27

    Re: Regarding Loops

    Quote Originally Posted by Arjay View Post
    Me too. Why not test both approaches and report back?
    I am not sure how I should test this lol.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,286

    Re: Regarding Loops

    Just code up it both ways and load test each (i.e. rather than testing only 10-1000 object per minute, try to max out the amount that can be processed in a minute). If there is a significant difference between the two approaches, go with the highest one; otherwise if they are about equal in performance, go with the one that is easier to maintain.

  5. #5
    Join Date
    May 2012
    Posts
    27

    Re: Regarding Loops


    Quote Originally Posted by Arjay View Post
    Just code up it both ways and load test each (i.e. rather than testing only 10-1000 object per minute, try to max out the amount that can be processed in a minute). If there is a significant difference between the two approaches, go with the highest one; otherwise if they are about equal in performance, go with the one that is easier to maintain.
    Thanks, but I ment that I don't know how to actually get benchmarks. Do I use Visual Studio? Also, what would be the most effecient way of making 1000 copies of an object without using a loop ? (So I can use it for testing)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center