Array performance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

from using FxCop and reading MSDN i understand that i should not use properties to access arrays, i should use methods instead,
however when i try the code below the MSIL for method and property access is identical, bar a slight differenc in code size and stack size.
What is the correct way to access an array, given that i need to perform actions on sections of the array as well as individual elements. Do I just access it directly? (in my actual app the array is 2 dimensional, approx 64k elements)

sample code:-
Private _a(100) As Integer
Public Property a() As Integer()
Get
Return _a
End Get
Set(ByVal Value() As Integer)
_a = Value
End Set
End Property
Public Function GetA() As Integer()
Return _a
End Function
Public Function SetA(ByVal x() As Integer) As Integer()
_a = x
End Function
 
Hi guy,

To test those things you can just set it in a loop than you know the
difference, not with a single

As timer you can take
dim start as integer = environment.tickcount
your process
dim endtime as integer = environment.tickcount - start

Cor
from using FxCop and reading MSDN i understand that i should not use
properties to access arrays, i should use methods instead,
however when i try the code below the MSIL for method and property access
is identical, bar a slight differenc in code size and stack size.
What is the correct way to access an array, given that i need to perform
actions on sections of the array as well as individual elements. Do I just
access it directly? (in my actual app the array is 2 dimensional, approx
64k elements)
 
Hi Guy,

What do you want to archieve in my opinon are you only passing a complete
array in all your samples, is that what you want to archieve?

So the time difference will me minimal between a method and a property

Cor
 
Hi Cor,
I need to perform processing on individual elements, for which a method would be fine, however I also need to do things like shifting blocks of elements up or down the array

Looks like I will just have to process the array directly

thanks

guy
 
Hi Guy,

And why do you not use the standard arrays as the arraylist, hashtable,
sortedlist and more of those?

Cor
 
Hi Cor,
I actually need to process a 2D array approx(300,200)
so 60K elements , which are 4 byte strucures. In the course of a run a very rough estimate is 60K*60K*2 accesses ie 7,200,000,000
plus 30K array shifts so i need real performance!
there is virtuallt no other processing, just array crunching

guy
 
Hi Guy,

Fixed or not Fixed?
With what I mean do you know in advance the size of it?

Cor

guy said:
Hi Cor,
I actually need to process a 2D array approx(300,200)
so 60K elements , which are 4 byte strucures. In the course of a run a
very rough estimate is 60K*60K*2 accesses ie 7,200,000,000
 
Hi Guy,

Go over to the language vb , I think that this needs a wider discussion than
only my opinion.

microsoft.public.dotnet.languages.vb

I agree it is not only language, however there you get more opinions.

(That is not that I will nog give my idea about this in that newsgroup,
however I think it is good to have in this huge array more opinions.)

Cor
 
Back
Top