zoukankan      html  css  js  c++  java
  • 测试Data ORM的性能

    闲着无聊,测试了一下公司ORM的性能,和其它的ORM相比,该有的都有了,不该有的也勉强塞了进去,总体考虑是并发与扩展性问题,譬如读写分离,消息总线服务整合,缓存内置。

    测试机是I7,16G内存,这里只根据测试场景写了最简单的数据库操作测试。

    采用了火地晋的测试工具,下面是测试代码

     1     public class DataTest :ITest
     2     {
     3 
     4         public void Init()
     5         {
     6         }
     7 
     8         public bool Insert()
     9         {
    10             var _repository = new Repository<DbAccessLibTest.Model.Test>();
    11             var model = new DbAccessLibTest.Model.Test();
    12             model.Guid = Guid.NewGuid().ToString();
    13             return _repository.Save(model, DbAccessLibTest.Model.Test._Guid) > 0;
    14         }
    15 
    16         public bool Update(string guid, string content)
    17         {
    18             var _repository = new Repository<DbAccessLibTest.Model.Test>();
    19             var model = new DbAccessLibTest.Model.Test();
    20             model.Content = content;
    21             return _repository.Update(model, DbAccessLibTest.Model.Test._Guid == guid, DbAccessLibTest.Model.Test._Content) > 0;
    22         }
    23 
    24         public System.Data.DataTable Select(int count)
    25         {
    26             var _repository = new Repository<DbAccessLibTest.Model.Test>();
    27             var list = _repository.Find(new QueryWhere(), count);
    28             return null;
    29         }
    30 
    31         public List<string> GetGuidList(int count)
    32         {
    33             var _repository = new Repository<DbAccessLibTest.Model.Test>();
    34             var list = _repository.Find(new QueryWhere(), count, null, 0, DbAccessLibTest.Model.Test._Guid);
    35             var guids = new List<string>();
    36             foreach (var test in list)
    37             {
    38                 guids.Add(test.Guid);
    39             }
    40             return guids;
    41         }
    42 
    43         public bool Delete(string guid)
    44         {
    45             var _repository = new Repository<DbAccessLibTest.Model.Test>();
    46             var model = new DbAccessLibTest.Model.Test();
    47             model.Guid = guid;
    48             return _repository.Delete(model) > 0;
    49         }
    50   }
    View Code

    大致了解了一下,一下采用10/100/500/1000个线程,10个查询测试,节省时间,直接和ClownFish对比

        Inset Delete Update Select
        平均值 最高 最低 平均值 最高 最低 平均值 最高 最低 平均值 最高 最低
    10线程 ClownFish 279 406 221 304 359 268 262 361 158 8 9 7
    MyData 475 720 249 527 727 244 462 705 253 10 13 8
    100线程 ClownFish 573 1246 154 646 1323 217 365 1117 140 8 22 6
    MyData 599 1716 320 730 1899 303 784 1771 291 10 14 8
    500线程 ClownFish 7097 22106 225 3691 19673 97 4017 20029 158 9 35 7
    MyData 591 1263 181 1416 8583 297 5556 27463 376 10 19 8
    1000线程 ClownFish 7967 30946 166 5502 21291 163 6300 28062 145 8 68 6
    MyData 606 1242 249 577 2719 203 608 1043 270 10 22 8

    总体来看,公司的ORM性能较ClowFish差上20%-50%,但性能较稳定,1000线程测试全部跑完,无异常产生,ClowFish在200线程以内无异常,200线程以后,出现(执行错误,信息:超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。)异常,导致执行时间波动较大。

    这个测试和原来公司压力测试结果差不多,压力测试公司ORM是直接ado.net执行的1.5倍性能左右。

  • 相关阅读:
    记忆力训练今天早上有了点小进步
    刻意练习
    12.12周计划
    12.6周总结
    The Power of Reading Insights
    Storytelling with Data
    nexus私服和快照正式版本etc
    springboot启动流程分析
    容器启动getBean的流程分析
    canal简介
  • 原文地址:https://www.cnblogs.com/keo2013/p/3322027.html
Copyright © 2011-2022 走看看