■82354 / inTopicNo.24) |
Re[7]: VBでCRC32を高速で計算する方法 |
□投稿者/ WebSurfer (1114回)-(2017/01/04(Wed) 17:26:32)
|
No82337 で紹介した、
> Calculating CRC-32 in C# and .NET
> https://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net
で試してみましたが、511MB のファイルが 4 秒前後でした。ご参考まで
Option Strict On
Module Module1
Sub Main()
Dim crc32 As New ClassLibrary1.Crc32
Dim hash As String = String.Empty
Dim path As String = "C:\test.zip"
Dim stopWatch As New Stopwatch
stopWatch.Start()
Using fs As System.IO.FileStream = System.IO.File.Open(path, System.IO.FileMode.Open)
For Each b As Byte In crc32.ComputeHash(fs)
hash += b.ToString("x2").ToLower()
Next
End Using
stopWatch.Stop()
Dim ts As TimeSpan = stopWatch.Elapsed
Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
Console.WriteLine("CRC-32 is {0}", hash)
Console.WriteLine(elapsedTime, "RunTime")
End Sub
End Module
|
|