C#如果使用较大的ViewState名称,性能会降低吗? [英] C# Does performance degrade if I use a large ViewState names?

查看:44
本文介绍了C#如果使用较大的ViewState名称,性能会降低吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我个人喜欢下面的选项一,因为它具有可维护性,但我可以看到选项二使我获得了更好的性能.选项三可能是完全垃圾.

I personally like option one below for maintainability but I could see option two getting me better performance. Option three is probably complete garbage.

1. ViewState["Calendar1.SelectionMode"] = Calendar1.SelectionMode;
2. ViewState["CSM"] = Calendar1.SelectionMode;
3. ViewState["Calendar1_SelectionMode"] = Calendar1.SelectionMode;

我是否采用旧式的养护习惯习惯?仅当对象数量很大时才重要吗?除了非常有效的哈希,我看不到内部使用任何东西.我已经阅读了一些加快页面加载速度的方法,但没有任何直接建议,因为这只是一个很小的因素.所有文献都在讨论使用紧凑类型仅填充那些采用非默认值的值,而不是数据库访问读取更喜欢视图状态.

Am I applying old school habits of thinking about the maintenance? Does it matter only when the number of objects is large? I cannot see the internals using anything but a very efficient hash. I have read up on methods to speed up the page loading but nothing directly advising as this being even a slight factor. All the literature talks about is prefering the viewstate over database access reads, using compact types, populating only those values that take on non default values.

推荐答案

选项二可能会为您提供更好的性能,但是差别很小.如果您遇到性能问题,这将是我寻找瓶颈的最后地方之一.您是否在页面上运行过任何类型的分析?那就是我开始寻找的地方.

Option two will probably give you better performance, but the difference is extremely small. If you're experiencing performance problems this would be one of the very last places I would look for bottlenecks. Have you run any kind of profiling on your page? That's where I would start looking.

这篇关于C#如果使用较大的ViewState名称,性能会降低吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆