PDA

Click to See Complete Forum and Search --> : Need suggestions: array or non-array?


edhanz
Jul 14th, 2009, 07:49 AM
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?

Hack
Jul 14th, 2009, 11:24 AM
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. :)

Shaggy Hiker
Jul 14th, 2009, 03:04 PM
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.