473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Array performance

guy
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
Jul 21 '05 #1
7 1463
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)
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

Jul 21 '05 #2
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
Jul 21 '05 #3
guy
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

"Cor Ligthert" wrote:
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

Jul 21 '05 #4
Hi Guy,

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

Cor
Jul 21 '05 #5
guy
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

"Cor Ligthert" wrote:
Hi Guy,

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

Cor

Jul 21 '05 #6
Hi Guy,

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

Cor

"guy" <gu*@discussions.microsoft.com> schreef in bericht
news:11**********************************@microsof t.com...
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

"Cor Ligthert" wrote:
Hi Guy,

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

Cor

Jul 21 '05 #7
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
Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Laphan | last post by:
Hi All I'm using .getRows() with a local var array instead of doing a recursive loop so that I'm being a good ASP newvbie and closing my object i/o's (the recordset in this case) as quick as...
7
by: Berislav Lopac | last post by:
Does anyone has experience/information about the performance of the array elements assignment? Specifically, which is more efficient: var myArray = new Array(a, b, c, d); or var myArray...
9
by: sangeetha | last post by:
Hello, Is there any performance difference in using of the following two declaration? int (*ptr); //Array of 10 int pointers int *ptr; // pointer-to-array of 10. Regards, Sangeetha.
4
by: Peter | last post by:
I run into this situation all the time and I'm wondering what is the most efficient way to handle this issue: I'll be pulling data out of a data source and want to load the data into an array so...
19
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0...
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
20
by: John Mark Howell | last post by:
I had a customer call about some C# code they had put together that was handling some large arrays. The performance was rather poor. The C# code runs in about 22 seconds and the equivalent...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
3
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
One more for today.... As I add more and more lines to my RichTextBox the array that holds its strings gets bigger and bigger and the vertical scroll bar gets smaller and smaller until the...
5
by: Immortal Nephi | last post by:
I would like to design an object using class. How can this class contain 10 member functions. Put 10 member functions into member function pointer array. One member function uses switch to call...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.