Results 1 to 3 of 3

Thread: Need suggestions: array or non-array?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2008
    Posts
    136

    Need suggestions: array or non-array?

    Hi,

    i made a client app to connect to server. it can connect 10 winsock at once (max 10 connections). for that purpose, i already made 2 versions to compare, using 10 winsock controls and the other one using 1 winsock control as array..

    after comparison of both versions, i found non-array winsock app has faster connection than the other one (although i like winsock array version most)..

    from what i've read on internet, it's said better not to use array if we already knew how many the maximum controls are used. in my case, since i only use max 10 connections, then it's better using 10 winsock control (not as array), since array will use more memory..

    so, what do you think about that?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Need suggestions: array or non-array?

    Moved To General Developer

    Anytime you do not have to use a control array is a good time. Since you never, really, need to use a control array, all times are good.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Need suggestions: array or non-array?

    I'm not so sure about what you read on the internet about it being 'better'. Unrolling a loop does have some performance advantages, so if you are looping through the array vs calling something on each of the 10 sockets in turn, I can see an advantage.

    However, there are two other considerations to keep in mind:

    1) Is it easier to maintain one over the other? You already stated that you prefer the array implementation. Is that because it makes for a neater solution that is easier to read? If so, that would argue for it, as design is temporary, but maintenance is forever.

    2) Is the performance difference enough to make a difference? Quite often, we worry about an extra cycle or two, when the timing of the whole design hangs on other points.
    My usual boring signature: Nothing

Posting Permissions

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



Click Here to Expand Forum to Full Width