Foxtable(狐表)用户栏目专家坐堂 → [求助]filler的机制问题


  共有2468人关注过本帖平板打印复制链接

主题:[求助]filler的机制问题

帅哥哟,离线,有人找我吗?
chnfo
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2195 积分:18043 威望:0 精华:0 注册:2011/11/26 20:21:00
[求助]filler的机制问题  发帖心情 Post By:2018/6/25 14:52:00 [只看该作者]

''
DataTables("D").DataRows.Clear
Tables("D").AddNew(10000)
For Each r As Row In Tables("D").Rows
r("C") = rand.NextString(12)
r("T") = rand.NextString(12)
r("U") = rand.NextString(12)
r("A") = rand.Next(500)
r("P") = rand.Next(1500)
Next

Dim st As Date = Date.Now
Dim log As String
Dim f As New Filler
f.SourceTable = DataTables("D") '指定数据来源
f.SourceCols = "C,T,U,A,P" '指定数据来源列
f.DataTable = DataTables("E") '指定数据接收表
f.DataCols = "C,T,U,A,P" '指定数据接收列
f.Fill()
log &=  "FILL耗时: " & (Date.Now - st).TotalSeconds & "秒" & vbcrlf

DataTables("E").DataRows.Clear
Dim st2 As Date = Date.Now
Dim x As new List(of DataRow)
For Each dr As DataRow In DataTables("D").DataRows
    x.Add(dr)
Next

log &=  "得到序列耗时: " & (Date.Now - st2).TotalSeconds & "秒" & vbcrlf

Dim n As Integer = x.Count
log &=  "得到行数耗时耗时: " & (Date.Now - st2).TotalSeconds & "秒" & vbcrlf

DataTables("E").AddNew(n)
log &=  "增加行耗时: " & (Date.Now - st2).TotalSeconds & "秒" & vbcrlf

For i As Integer = 0 To n - 1
    Dim dr As DataRow = DataTables("E").DataRows(i)
    dr("C") = x(i)("C")
    dr("T") = x(i)("T")
    dr("U") = x(i)("U")
    dr("A") = x(i)("A")
    dr("P") = x(i)("P")
Next
log &=  "赋值耗时: " & (Date.Now - st2).TotalSeconds & "秒" & vbcrlf
output.Show(log)

实际测试,如果10000行以内,两种方法相差1秒,但超过万行,达到10万行数据以后,filler需要13秒左右,而后一种方法耗时2倍。
后一种方法还能更快一些吗?

 回到顶部