选择显示字体大小

nhibernate与ado.net查询速度的比较(2)

     using system;
  using system.collections;
  using system.componentmodel;
  using system.data;
  using system.drawing;
  using system.text;
  using system.windows.forms;
  
  namespace nhibernatetestui
  {
   public partial class orderfrm : form
   {
   public orderfrm()
   {
   initializecomponent();
   }
  
   nhibernatetest.order order = new nhibernatetest.order();
  
   /**//// <summary>
   /// 使用nhibernate hql方式查询
   /// </summary>
   private void btnnhload_click( object sender, eventargs e )
   {
   string stroutput = "";
  
   // 测试加载数据时间
   datetime dtstart = system.datetime.now;
   ilist orders = order.loadallbynhibernate(); // 使用nhibernate hql方式查询
   datetime dtend = system.datetime.now;
   timespan ts = dtend - dtstart;
   stroutput += "nhibernate hql方式 : "
   + orders.count + " 条记录, 加载时间(ms) : "
   + ts.totalmilliseconds;
  
  
   // 测试绑定数据时间
   dtstart = system.datetime.now;
   this.dgvorders.datasource = orders;
   dtend = system.datetime.now;
   ts = dtend - dtstart;
   stroutput += " 绑定ilist时间 : " + ts.totalmilliseconds;
  
   console.writeline( stroutput );
   }
  
   /**//// <summary>
   /// 使用ado.net dbdataadapter方式查询
   /// </summary>
   private void btnadoload_click( object sender, eventargs e )
   {
   string stroutput = "";
  
   // 测试加载数据时间
   datetime dtstart = system.datetime.now;
   datatable dtorders = order.loadallbyad.net(); // 使用ado.net dbdataadapter方式查询
   datetime dtend = system.datetime.now;
   timespan ts = dtend - dtstart;
   stroutput += "ado.net dbdataadapter方式 : "
   + dtorders.rows.count + " 条记录; 加载时间(ms) : "
   + ts.totalmilliseconds;
  
   // 测试绑定数据时间
   dtstart = system.datetime.now;
   this.dgvorders.datasource = dtorders;
   dtend = system.datetime.now;
   ts = dtend - dtstart;
   stroutput += " 绑定ilist时间 : " + ts.totalmilliseconds;
  
   console.writeline( stroutput );
   }
   }
  }
  
  运行后界面如下:
  
  
  
  在界面两个按钮点击多次后,两者的查询时间稳定,可以作为比较。下面是输出:
  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
  
  
  另外在网上找了一下关于nhibernate性能的讨论的有,
  http://kevin-y.cnblogs.com/archive/2006/02/08/327164.html
  http://wljcan.cnblogs.com/archive/2005/05/14/155495.aspx
  很少,希望能有已经做过nhibernate考量的高手提供点路子,非常感谢。
    


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons