« What's WebLOG | Main | ドライヴ容量取得 »

Line Input と TextStreamではどっちが速い?

'Line Input と TextStreamではどっちが速い?
Function TextStreamReadWrite_LateBind(FileName As String)
Dim fs As Object, a As Object, i As Long, r_data As String, t As Long
'10万件書き出し
Debug.Print nowtime(): t = GetTickCount
r_data = "This is a test."
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(FileName, True)
For i = 1 To 100000
a.WriteLine r_data & Format$("000000", i)
Next i
a.Close
Set a = Nothing
'10万件の行末までスキップ&読み出し
Debug.Print nowtime(), GetTickCount
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(FileName, 1, 0)
For i = 1 To 99999
a.SkipLine
Next i
r_data = a.ReadLine
a.Close
Debug.Print nowtime(), GetTickCount - t
Set fs = Nothing
Set a = Nothing
End Function
Function TextStreamReadWrite_EarlyBind(FileName As String)
Dim fs As New FileSystemObject, a As TextStream, i As Long, r_data As String, t As Long
'10万件書き出し
Debug.Print nowtime(): t = GetTickCount
r_data = "This is a test."
Set a = fs.CreateTextFile(FileName, True)
For i = 1 To 100000
a.WriteLine r_data & Format$("000000", i)
Next i
a.Close
Set a = Nothing
'10万件の行末までスキップ&読み出し
Debug.Print nowtime(), GetTickCount
Set a = fs.OpenTextFile(FileName, 1, 0)
For i = 1 To 99999
a.SkipLine
Next i
r_data = a.ReadLine
a.Close
Debug.Print nowtime(), GetTickCount - t
Set fs = Nothing
Set a = Nothing

End Function
Function LineInputReadWrite(FileName As String)
Dim i As Long, r_data As String, t As Long
'10万件書き出し
Debug.Print nowtime(): t = GetTickCount
r_data = "This is a test."
Open FileName For Output As #1
For i = 1 To 100000
Print #1, r_data & Format$("000000", i)
Next i
Close #1
'10万件の行末までスキップ&読み出し
Debug.Print nowtime(), GetTickCount
Open FileName For Input As #1
For i = 1 To 99999
Line Input #1, r_data
Next i
Line Input #1, r_data
Close #1
Debug.Print nowtime(), GetTickCount - t
End Function

|

« What's WebLOG | Main | ドライヴ容量取得 »

Comments

Post a comment



(Not displayed with comment.)




TrackBack

TrackBack URL for this entry:
http://app.cocolog-nifty.com/t/trackback/4099/22582

Listed below are links to weblogs that reference Line Input と TextStreamではどっちが速い?:

« What's WebLOG | Main | ドライヴ容量取得 »