简而言之,什么方法效果更快:
- SessionFactory 预编译 XML
配置,或
- 流畅的 NHibernate 提供
以编程方式配置 ?
我个人的经验是,配置对象的构建(无论是否使用 Fluent,这是不可避免的*)通常会使设置 FluentConfiguration 对象所需的时间相形见绌,并且随着映射数量的增加,该因子也会增加。
在 2.5 Ghz c2d 上,我的项目大约有 15 个映射,FluentConfiguration 花费了 360ms,Configuration 花费了 5215ms。
在具有 1000 个映射(具有 2-3 个字符串属性的简单类)的测试项目中,FluentConfiguration 花费了 470 毫秒,Configuration 花费了 40336 毫秒(40 秒!)。
*Actually, not really. most of the cost of Configuration comes from validating the XML mappings. Ayende has discussed it here (as well as a quick speedup obtained from merging the mappings into a single file), and a possible alternative to building the configuration at application startup is to serialize it as discussed here. In the 1000-mapping test project, this reduced the time required to get a Configuration object to around 30ms (although it has also increased the time required to build the SessionFactory from ~3 to ~4 seconds - I am unsure why).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)