Re: Framework 2.0 array redim unsatisfactory performance



Tom,
| My tests show that generic based List<> uses at least 5 additional bytes
for
| each entry. Not a surprise, most likely it is implemented as single-linked
| list. In most applications it is not a concern, but in my cases it is.

List(Of T) is implemented as an Array not a single-linked list, per:

http://msdn2.microsoft.com/library/6sh2ey19(en-us,vs.80).aspx

<quote>
Implements the System.Collections.Generic.IList<> interface using an array
whose size is dynamically increased as required.

</quote>

Note it states "using an array whose size is dynamically increased", this is
the double action I was referring to.

How are you determining "at least 5 additional bytes for each entry"?

You are testing against a List(Of Integer) & not List(Of Object) where each
element is being boxed?

Are you looking at the Capacity compared to Count? Capacity needs to be
larger as this is where the performance comes in. Rather then alloc a new
array & copy all the elements for each element added.

Yes there is some overhead as compared to an array, however I would expect
this to be 4 to 12 bytes per instance of List(Of T), not per element.

FWIW: List(Of T) is the generic version of ArrayList. A couple of advantages
of List(Of T) are that it avoids the "boxing penalty" that ArrayList has,
plus it ensures type safety.

Hope this helps
Jay


"Tom Jastrzebski" <tom@xxxxxxx> wrote in message
news:rNVJe.122$O07.93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| Jay,
|
|
|
| Whether Integer or Long type is being used of course makes a difference.
| However, my tests show that this difference is not that significant, and
| still old good VB 6.0 performs way better.
|
|
|
| The reason why I test Array is because I need a dynamic data structure
with
| as small memory overhead as possible.
|
| My tests show that generic based List<> uses at least 5 additional bytes
for
| each entry. Not a surprise, most likely it is implemented as single-linked
| list. In most applications it is not a concern, but in my cases it is.
|
|
|
| Since dynamic array is not available in C# I was just wondering how
| efficient this VB structure was before starting thinking about alternative
| approaches using C++.
|
|
|
| Thanks,
|
| Tomasz
|
|


.



Relevant Pages

  • Re: This question seems simpler than it actually is...
    ... find a lot of logic designers forget what HDL stands for... ... For the exercise I went ahead and did this with a 6 element array. ... type invect is array of entry; ... case mystate is ...
    (comp.lang.vhdl)
  • Re: A critique of test-first...
    ... > silly to give a coding test to people of our level; ... Each message will have the cummulative probability. ... To find a random message get a number from randand find the entry ... Use a sparse/dense array of chars. ...
    (comp.programming)
  • Re: A critique of test-first...
    ... > silly to give a coding test to people of our level; ... Each message will have the cummulative probability. ... To find a random message get a number from randand find the entry ... Use a sparse/dense array of chars. ...
    (comp.programming)
  • Re: Removing entry from @rray
    ... For some time I have been using two different method for removing an entry ... and places each line into the array. ... Redefining the @array element inside to loop ...
    (comp.lang.perl.misc)
  • Re: any function to handle this kind of counting?
    ... the OP would find APL equally as opaque as OCaml. ... rebuilding the dynamic data structure as you go is gonna be ... > So a brute force array-based implementation computes 40 times more ... Or size the array using two passes. ...
    (comp.programming)