![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am building the application which is writes in C# and needs goog performance. I optimalize it in the .NET Framework .NET 1.1. Then I am start using of .NET beta Framework 2.0 beta 1, than beta 2 and now Release canditate. But now performence decreased. I am using generics for usin collection and I am not using foreach if I not have to. Is bag in VS 2005 RC or I must go back to .NET 1.1 for fast code in .NET C#. |
#3
| |||
| |||
|
|
John <John (AT) discussions (DOT) microsoft.com> wrote: I am building the application which is writes in C# and needs goog performance. I optimalize it in the .NET Framework .NET 1.1. Then I am start using of .NET beta Framework 2.0 beta 1, than beta 2 and now Release canditate. But now performence decreased. I am using generics for usin collection and I am not using foreach if I not have to. Is bag in VS 2005 RC or I must go back to .NET 1.1 for fast code in .NET C#. Could you post a short but complete program which demonstrates the problem? See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that. Where is your performance bottleneck? Note that using foreach doesn't significantly decrease performance in most situations, and can even increase the performance in some situations. More than that, it tends to give more easily readable code - so I'd use it anywhere it's useful unless you can *prove* that in that particular situation it's hurting performance significantly. -- Jon Skeet - <skeet (AT) pobox (DOT) com http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
#4
| |||
| |||
|
|
Jon is right about the for vs foreach loops. foreach has a bit of overhead, but unless your iterating about 25 million times you wont see a difference...and even then its really small. One common mistake that people make when migrating to 2.0 is to go Generics crazy, and turn every arraylist and hashtable they have into a generic one. but consider that the C# (or JIT, i'm not sure) compiler will take every generic list and generate code to make it strongly typed. so every Interface and object used to make an ArrayList will be duplicated in memory per type the generic object is bound to. |
#5
| |||
| |||
|
|
john conwell <johnconwell (AT) discussions (DOT) microsoft.com> wrote: Jon is right about the for vs foreach loops. foreach has a bit of overhead, but unless your iterating about 25 million times you wont see a difference...and even then its really small. One common mistake that people make when migrating to 2.0 is to go Generics crazy, and turn every arraylist and hashtable they have into a generic one. but consider that the C# (or JIT, i'm not sure) compiler will take every generic list and generate code to make it strongly typed. so every Interface and object used to make an ArrayList will be duplicated in memory per type the generic object is bound to. No, that's not true. Reference types all get a single implementation shared between them, and then there's an implementation per value type. It's worth making everything you can generic, not for performance reasons, but for safety and readability. -- Jon Skeet - <skeet (AT) pobox (DOT) com http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
#6
| |||
| |||
|
|
john conwell <johnconwell (AT) discussions (DOT) microsoft.com> wrote: Jon is right about the for vs foreach loops. foreach has a bit of overhead, but unless your iterating about 25 million times you wont see a difference...and even then its really small. One common mistake that people make when migrating to 2.0 is to go Generics crazy, and turn every arraylist and hashtable they have into a generic one. but consider that the C# (or JIT, i'm not sure) compiler will take every generic list and generate code to make it strongly typed. so every Interface and object used to make an ArrayList will be duplicated in memory per type the generic object is bound to. No, that's not true. Reference types all get a single implementation shared between them, and then there's an implementation per value type. It's worth making everything you can generic, not for performance reasons, but for safety and readability. -- Jon Skeet - <skeet (AT) pobox (DOT) com http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
#7
| |||
| |||
|
|
god, i love MVPs. Actually, no. Reference types dont all get one single implementation. Its true that they do share SOME code between them, but SOME code will get duplicated by type. |
#8
| |||
| |||
|
|
In that case, MSDN is wrong. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |