NHibernate HQL方式 : 830 条记录, 加载时间(ms) : 3334.7952 绑定IList时间(ms) : 70.1008
Ado.Net DbDataAdapter方式 : 830 条记录; 加载时间(ms) : 40.0576 绑定IList时间(ms) : 80.1152
测试环境:WinForm方式,数据库也在本机
硬件:CPU -- 1.2G AMD duron(tm) RAM -- 384M DDR266
软件:Windows Server 2003, Sql Server 2000,Visual Studio.Net 2005
测试代码下载http://www.cnblogs.com/Files/liuyuanhuo/NHibernateTest_Performance.rar
测试的代码是在子非鱼 NHibernate学习http://sifang2004.cnblogs.com/archive/2005/09/05/230713.aspx
NHibernate 博客园专题之一http://www.cnblogs.com/Files/sifang2004/NHibernateTest.rar中下载的示例中作修改的。
测试由两个工程组成,
一.NHibernateTest工程,仅修改两个地方
1.注释Order.hbm.xml中_Items相关的<bag元素
2.在Order.cs增加下面两个方法
|
|
运行后界面如下:
在界面两个按钮点击多次后,两者的查询时间稳定,可以作为比较。下面是输出:
NHibernate :select order0_.orderId as orderId, order0_.shippedDate as shippedD4_, order0_.shipPostalCode as shipPos10_, order0_.requiredDate as required3_, order0_.shipCountry as shipCou11_, order0_.shipVia as shipVia, order0_.orderDate as orderDate, order0_.shipAddress as shipAddr7_, order0_.shipRegion as shipRegion, order0_.shipName as shipName, order0_.shipCity as shipCity, order0_.customerId as customerId, order0_.freight as freight, order0_.employeeId as employeeId from Orders order0_
NHibernate HQL方式 : 830 条记录, 加载时间(ms) : 3334.7952 绑定IList时间 : 70.1008
NHibernate :select order0_.orderId as orderId, order0_.shippedDate as shippedD4_, order0_.shipPostalCode as shipPos10_, order0_.requiredDate as required3_, order0_.shipCountry as shipCou11_, order0_.shipVia as shipVia, order0_.orderDate as orderDate, order0_.shipAddress as shipAddr7_, order0_.shipRegion as shipRegion, order0_.shipName as shipName, order0_.shipCity as shipCity, order0_.customerId as customerId, order0_.freight as freight, order0_.employeeId as employeeId from Orders order0_
NHibernate HQL方式 : 830 条记录, 加载时间(ms) : 3304.752 绑定IList时间 : 70.1008
NHibernate :select order0_.orderId as orderId, order0_.shippedDate as shippedD4_, order0_.shipPostalCode as shipPos10_, order0_.requiredDate as required3_, order0_.shipCountry as shipCou11_, order0_.shipVia as shipVia, order0_.orderDate as orderDate, order0_.shipAddress as shipAddr7_, order0_.shipRegion as shipRegion, order0_.shipName as shipName, order0_.shipCity as shipCity, order0_.customerId as customerId, order0_.freight as freight, order0_.employeeId as employeeId from Orders order0_
NHibernate HQL方式 : 830 条记录, 加载时间(ms) : 3354.824 绑定IList时间 : 80.1152
Ado.Net DbDataAdapter方式 : 830 条记录; 加载时间(ms) : 40.0576 绑定IList时间 : 80.1152
Ado.Net DbDataAdapter方式 : 830 条记录; 加载时间(ms) : 40.0576 绑定IList时间 : 90.1296
Ado.Net DbDataAdapter方式 : 830 条记录; 加载时间(ms) : 30.0432 绑定IList时间 : 90.1296
NHibernate :select order0_.orderId as orderId, order0_.shippedDate as shippedD4_, order0_.shipPostalCode as shipPos10_, order0_.requiredDate as required3_, order0_.shipCountry as shipCou11_, order0_.shipVia as shipVia, order0_.orderDate as orderDate, order0_.shipAddress as shipAddr7_, order0_.shipRegion as shipRegion, order0_.shipName as shipName, order0_.shipCity as shipCity, order0_.customerId as customerId, order0_.freight as freight, order0_.employeeId as employeeId from Orders order0_
NHibernate HQL方式 : 830 条记录, 加载时间(ms) : 3334.7952 绑定IList时间 : 70.1008
Ado.Net DbDataAdapter方式 : 830 条记录; 加载时间(ms) : 50.072 绑定IList时间 : 90.1296
(责任编辑 火凤凰 sunsj@51cto.com TEL:(010)68476636-8007)