Coding performances


Indexed positions are always going to be faster than string comparisons, not matter what the context of the collection is. Still, even faster would be to use protected members of your class, which ASP.NET will automatically set if you are using usercontrol or web forms. The style code isn't going to make much difference either way, but I would recommend setting the actual property (ie. BackColor instead), since the webcontrols support down level rendering when you use these properties.

If you are so concerned about performance that you need to be wondering about the impact of things like this, you might want to take a look at output caching or just bypass web controls all together and directly output HTML using the Render method instead.

From
Jesse Ezell

First thanks for your comment. I will do as you say for the controls properties.
For output caching, that's another story.
the site I build is portal with a lot of things going on on each page.

I tried different options for caching, but it doesn't work very well.
I need a level of granularity for each object, and apparently I can't have on a same page very different cache functions.
Render HTML controls directly yes this is an option which I keep for when I will have time.

My post was also about finding something to help on performance checking.
It's not just tracing, but it's more about what the .Net community think about using a method rather than another.

1 Comment

  • You can cache at the control level. If you are using ascx files, the directive works the same as the page caching directive. If you are using custom/composite controls, then you have to do some footwork to cache the results, but the Cache object is both powerful and easy to use, so you can give whatever granularity you want without much difficulty.

Comments have been disabled for this content.