博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
测试Data ORM的性能
阅读量:4563 次
发布时间:2019-06-08

本文共 2695 字,大约阅读时间需要 8 分钟。

闲着无聊,测试了一下公司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
();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
();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
();27 var list = _repository.Find(new QueryWhere(), count);28 return null;29 }30 31 public List
GetGuidList(int count)32 {33 var _repository = new Repository
();34 var list = _repository.Find(new QueryWhere(), count, null, 0, DbAccessLibTest.Model.Test._Guid);35 var guids = new List
();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
();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倍性能左右。

 

 

 

转载于:https://www.cnblogs.com/keo2013/p/3322027.html

你可能感兴趣的文章
【Java初探02】——Java语言基础
查看>>
leetcode 48. Rotate Image
查看>>
Windows 7下java SDK下载、安装及环境变量设置
查看>>
java 自定义序列化
查看>>
把Windows7启动栏上的库修改为我的电脑
查看>>
在 Win32 Application 和 Win32 Console Application 中使用 MFC
查看>>
angular 2+ 路由守卫
查看>>
存储过程
查看>>
关于解决乱码问题的一点探索之一(涉及utf-8和GBK)
查看>>
Decomposition
查看>>
Visual Studio 配色方案 –> DarkColorful v1.0 发布
查看>>
水仙花数(无聊ing)
查看>>
saprk2 structed streaming
查看>>
由scanf说起之2:由scanf看 不同类型变量的变量名和内存的关系
查看>>
C++临时对象
查看>>
【转】同一台电脑关于多个SSH KEY管理
查看>>
luogu1377 树的序 (线段树)
查看>>
luogu1984 烧水问题 (找规律)
查看>>
一款工作记录软件
查看>>
BZOJ 3555: [Ctsc2014]企鹅QQ( hash )
查看>>