Re: Generic collections vs. arrays on structs vs. class



I have forgotten to say something that might be important as well:
Memory consumption and performance depends on the language you are using. Although c# and vb are both .net languages vb needs more memory (and therefore has to read and write more) because of its compatibility to vb6.

Yours,
Lukas Cavigelli
http://www.cavigelli.net

"Nip" <admin@xxxxxxxxxxxxx> schrieb im Newsbeitrag news:0CB86D5D-02E9-437C-9AE4-8689824F87BA@xxxxxxxxxxxxxxxx
Hi

I have lately written an app to measure exactly this.
I came to the result, that an array of classes is the fastest, but structs are much less memory consuming.
About the idea of generic collections: their performance is extremely bad (i got a 4x better performance with arrays).

--
Yours,
Lukas Cavigelli
http://www.cavigelli.net
"buu" <aha@xxxxx> schrieb im Newsbeitrag news:elpl4j$s9b$1@xxxxxxxxxxxxxxxx
I started working on a performance demanding app. I created structures that I put into an Array. Then I realized that arrays are byref objects, while struct is byval.
Now, I presumed, that managing these objects would be faster if I would use class instead of structure, cause I can send a reference, not the whole object as an procedure parameter. Am I right?


but.... I realized that it would be very good to use generic collections instead of array (that keeps classes). Would it be faster than structs on arrays? (or even classes put in arrays).

Also, wich kind of generic collections would be the best for it?
These objects have one primary key (because of it Dictionary is one possibility), but that object has 2-3 index keys wich are often used, but they're not unique.
Wich way you recomend?



.



Relevant Pages

  • Re: Copying from one struct to another, simple assignment?
    ... Are, but with this change to the language you could compare structs, so allowing to compare structs inside structs make sense :-) ... allowed arrays to be assigned indirectly. ... The semantics are straightforward. ... Although based on Larry's answer of comp.std.c there is unlikely to be a struct comparison added to the language. ...
    (comp.lang.c)
  • Re: array
    ... structs. ... why arrays can't do this? ... Because that's the way the language is designed. ... Keith Thompson kst-u@xxxxxxx ...
    (comp.lang.c)
  • Re: Theodore Adorno, a prophet of data systems design
    ... I have a program which reads the log file looking for leaks.) ... > The second objection is that the C language leaves certain behaviours ... the way in which C allocates arrays and fails to ... >> The ideal is in fact to be able to create a string, ...
    (comp.programming)
  • Re: why cant functions return arrays
    ... The real problem with the idea of changing C to allow arrays to be ... treated as first-class objects is that there's no good way to do so ... The C language is already quite useful, ... but is really a pointer). ...
    (comp.lang.c)
  • Re: A VB.NET Critique
    ... You believe certain types, like strings and arrays, shouldn't be ... Should the language still ... They *aren't* reference types. ... Under your scheme, every new rectangle declaration just broke, and broke ...
    (comp.programming)

Loading