PC Review


Reply
Thread Tools Rate Thread

ArrayList vs Arrays - Performance

 
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      15th Aug 2004
I wish to build up a byte array from various sources of different lengths. I
can either use a byte array and redimension it as needed as I add the various
values or use an arraylist which automatically expands as required then
convert it to an array after I finish adding the elements. Does anyone know
which would be faster considering that I would probably have about 10 redim
statements if I use a byte array. Microsoft's literature suggests using an
arraylist would be better but I don't always trust M'soft.
--
Dennis in Houston
 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      15th Aug 2004
Dennis,

>Does anyone know
>which would be faster considering that I would probably have about 10 redim
>statements if I use a byte array.


Can't you allocate a byte array that is larger than you initially
need, to reduce the number of ReDims?

I'd avoid ArrayList when working with bytes due to the boxing
overhead.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      16th Aug 2004
What is "boxing overhead"?

"Mattias Sjögren" wrote:

> Dennis,
>
> >Does anyone know
> >which would be faster considering that I would probably have about 10 redim
> >statements if I use a byte array.

>
> Can't you allocate a byte array that is larger than you initially
> need, to reduce the number of ReDims?
>
> I'd avoid ArrayList when working with bytes due to the boxing
> overhead.
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Aug 2004
Dennis,

> Microsoft's literature suggests using an arraylist would be better
>but I don't always trust M'soft.


Why do you have doubts in the case of the arraylist.

It is a list that adds a reference against redimmension a complete array.

When you have doubts about that than you would start in my opinion as well
checking if a multiply operator is faster than a repeated add.

Just my thought,

Cor


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Aug 2004
* =?Utf-8?B?RGVubmlz?= <(E-Mail Removed)> scripsit:
> What is "boxing overhead"?


<URL:http://msdn.microsoft.com/library/en-us/csref/html/vclrfboxingconversionpg.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      17th Aug 2004
Obviously someone disagrees with you, i.e., post from mattias.

"Cor Ligthert" wrote:

> Dennis,
>
> > Microsoft's literature suggests using an arraylist would be better
> >but I don't always trust M'soft.

>
> Why do you have doubts in the case of the arraylist.
>
> It is a list that adds a reference against redimmension a complete array.
>
> When you have doubts about that than you would start in my opinion as well
> checking if a multiply operator is faster than a repeated add.
>
> Just my thought,
>
> Cor
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arraylist of arrays wolima Microsoft C# .NET 3 6th Nov 2007 11:30 PM
ArrayList of arrays Zenon Microsoft C# .NET 3 15th Dec 2006 03:22 AM
.NET 2.0 performance bug in ArrayList.Sort =?Utf-8?B?QWxleCBDaHVkbm92c2t5?= Microsoft Dot NET 48 1st May 2006 11:00 AM
Arraylist Performance Issue Danny Microsoft VB .NET 4 15th Jan 2004 04:04 PM
Using Arraylist with arrays Vaden95 Microsoft Dot NET 2 8th Jul 2003 07:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:56 AM.