HFSoft.Data持久化组件和其他组件性能对比测试

       现在没有改版后的组件版本所以暂时用旧版的,由于组件存在的Bug所以导致某些情况不能测试成功,在修改了某些字段类型才能进行测试.测试方法是采用http://www.cnblogs.com/teddyma/archive/2007/07/26/831646.html 的测试代码在基础上添加了HFSoft.Data的测试功能。

测试代码:

    public class HFSoftPerformanceTest : IPerformanceTest

    {

        #region IPerformanceTest 成员

 

        public long ExecuteSmallRead(int repeatTime)

        {

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            sw.Reset();

            sw.Start();

            Expression exp;

            for (int i = 0; i < repeatTime; i++)

            {

              

                exp = DB.Categories.CategoryID == 10;

                IList<Categories> cast = exp.List<Categories>();

 

                exp = DB.Customers.CustomerID == "10";

                IList<Customers> cuses = exp.List<Customers>();

              

                exp = DB.Products.ProductID == 10;

                IList<Products> products = exp.List<Products>();

            }

          

            sw.Stop();

            return sw.ElapsedMilliseconds;

        }

 

        public long ExecuteBigRead(int repeatTime)

        {

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            sw.Reset();

            sw.Start();

           

            for (int i = 0; i < repeatTime; i++)

            {

                IList<Categories> cats = DaoContext.List<Categories>(null);

                IList<Customers> cuses = DaoContext.List<Customers>(null);

                IList<Products> products = DaoContext.List<Products>(null);

            }

          

            sw.Stop();

            return sw.ElapsedMilliseconds;

        }

 

        public long ExecuteWrite(int repeatTime)

        {

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            sw.Reset();

            sw.Start();

            //...

            sw.Stop();

            return sw.ElapsedMilliseconds;

        }

 

        #endregion

    }

测试结果:

Compare small read performance of ADO.NET, NBearV3, NHibernateV1, NBearLite, NBearLite+NBearMapping,HFSoft.

Repeat Time = 2

3     12    4     10    18    3    

Repeat Time = 5

10    31    6     26    45    6    

Repeat Time = 10

16    57    13    63    87    12   

 

Compare big read performance of ADO.NET, NBearV3, NHibernateV1, NBearLite, NBearLite+NBearMapping,HFSoft

Repeat Time = 2

70    1143              203  76    227  71   

Repeat Time = 5

198  3307       468  233  395  189 

Repeat Time = 10

453  7103       940  470  905  432 

 

Compare write performance of ADO.NET, NBearV3, NHibernateV1, NBearLite, NBearLite+NBearMapping,HFSoft

Repeat Time = 2

9     40    18    33    36    0    

Repeat Time = 5

19    99    50    88    99    0    

Repeat Time = 10

155  272  108  286  202  0    

由于这版本的持久组件在某些类型转上有问题,所以没有进行写操作测试。从测试的结果可以看到HFSoft持久化组件在读操作上优越于ado.net的代码;当然实际情况并不是如些,只是这段ado.net的代码和使用的DataSet作为载体的原因。等NClay改版完成后再作一个全面的比较测试。
以下是之前版的测试结果:
http://www.cnblogs.com/henryfan/archive/2006/12/10/588264.html

posted on 2007-07-26 13:28  henry  阅读(720)  评论(2编辑  收藏  举报

导航