20元现金领取地址:http://jdb.jiudingcapital.com/phone.html
内部邀请码:C8E245J (不写邀请码,没有现金送)

国内私募机构九鼎控股打造,九鼎投资是在全国股份转让系统挂牌的公众公司,股票代码为430719,为“中国PE第一股”,市值超1000亿元。

 

由于刚好看到网上的一篇帖子,所以做了这个测试。测试结果发现:
1、DataView.RowsFilter 比 DataTable.Select 性能低很多。查询了MSDN ,发现 DataView 重要的一个功能就是 “筛选”数据,为什么性能还不如 DataTable.Select() 呢?
2、当做 1000w 数据测试时,出现了 SystemOutOfMemory 的异常。主要在这句:
   // 1000w 数据时,出现了 SystemOutOfMemory 的异常
   row = mDataTable.NewRow();
   问题是:难道使用 NewRow() 时,有上限限制?
3、1000w 数据测试时,出现一个现象 :添加前300w 数据时,时间花费都差不多;300-400w 时,时间是前面的一倍;400-500w 时间更是长久;好像越到后来时间越长?为什么呢?
   1000w 数据测试“循环添加数据”功能的结果:
      Adding data ...
      Readed 1000000 rows [ 7651.0016 ms]...
      Readed 2000000 rows [ 8341.9952 ms]...
      Readed 3000000 rows [ 7030.1088 ms]...
      Readed 4000000 rows [ 24545.2944 ms]...
      Readed 5000000 rows [ 70251.016 ms]...
      Readed 6000000 rows [ 369591.4464 ms]...
      Readed 7000000 rows [ 668561.344 ms]...
      Readed 8000000 rows [ 1384751.1744 ms]...
      // 再往下就出现了 2 中所描述的异常
人老实,测试这么做也是没有办法,自己测试时,发现了好多需要改进的地方,希望大家不要见笑,帮我看看上面的问题,谢谢!

    测试代码:

测试代码

 

    测试结果:

ROWS COUNT :50w
Readed 50000 rows [ 230.3312 ms]...
Readed 100000 rows [ 240.3456 ms]...
Readed 150000 rows [ 390.5616 ms]...
Readed 200000 rows [ 220.3168 ms]...
Readed 250000 rows [ 250.36 ms]...
Readed 300000 rows [ 450.648 ms]...
Readed 350000 rows [ 220.3168 ms]...
Readed 400000 rows [ 240.3456 ms]...
Readed 450000 rows [ 340.4896 ms]...
Readed 500000 rows [ 220.3168 ms]...
cost [ 3034.3632 ms ] to add [ 50w ] rows.
----- AddData() END -----

cost [ 8321.9664 ms ] mDataTable.PrimaryKey...
cost [ 26658.3328 ms ] mDataTable.DefaultView...
PrimaryKey Columns Details;
Column Name:  index
Column DataType:  Double
Column Name:  content
Column DataType:  String
cost [ 34980.2992 ms ] to AddPrimaryKey().
----- AddPrimaryKey() END -----

running 1 times ...
mDataTable.Select("index < 80000"):
 440.6336 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3304.752 ms
dv.RowFilter = "index < 80000":
 27880.0896 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 28591.112 ms


running 2 times ...
mDataTable.Select("index < 80000"):
 430.6192 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3254.68 ms
dv.RowFilter = "index < 80000":
 28120.4352 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 28200.5504 ms


running 3 times ...
mDataTable.Select("index < 80000"):
 410.5904 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3244.6656 ms
dv.RowFilter = "index < 80000":
 28070.3632 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 28721.2992 ms


running 4 times ...
mDataTable.Select("index < 80000"):
 430.6192 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3244.6656 ms
dv.RowFilter = "index < 80000":
 27719.8592 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 27960.2048 ms


running 5 times ...
mDataTable.Select("index < 80000"):
 410.5904 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3555.112 ms
dv.RowFilter = "index < 80000":
 27970.2192 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 28170.5072 ms


running 6 times ...
mDataTable.Select("index < 80000"):
 430.6192 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3284.7232 ms
dv.RowFilter = "index < 80000":
 28671.2272 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 28150.4784 ms


running 7 times ...
mDataTable.Select("index < 80000"):
 440.6336 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3254.68 ms
dv.RowFilter = "index < 80000":
 27639.744 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 27970.2192 ms


running 8 times ...
mDataTable.Select("index < 80000"):
 420.6048 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3214.6224 ms
dv.RowFilter = "index < 80000":
 27389.384 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 27820.0032 ms


running 9 times ...
mDataTable.Select("index < 80000"):
 430.6192 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3184.5792 ms
dv.RowFilter = "index < 80000":
 27529.5856 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 27709.8448 ms


running 10 times ...
mDataTable.Select("index < 80000"):
 430.6192 ms
mDataTable.Select("index < 80000 or (content LIKE '%200%')"):
 3194.5936 ms
dv.RowFilter = "index < 80000":
 27339.312 ms
dv.RowFilter = "index < 80000 or (content LIKE '%200%')":
 28020.2912 ms

 

cost [ 596657.952 ms ] to WHILE loop.

 


--
 宝剑锋从磨砺出,梅花香自苦寒来
 
           我欲仗剑走天涯

http://blog.csdn.net/alonesword

posted on 2007-07-01 13:24  孤剑  阅读(14743)  评论(3编辑  收藏  举报