Created
October 19, 2017 21:32
-
-
Save JKamsker/4ce64ee099c1adb7dd3a2a087e1c9711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void TestFifo(Stream cStream) | |
{ | |
int readbytes; | |
int crbytes; | |
var buf = new byte[10 * 1024 * 1024]; | |
var cBuf = new byte[255 * 1024]; | |
var sInfo = new FileInfo(@"D:\Work\Video Editing\Raw\Overwatch\Overwatch 10.17.2017 - 23.59.39.01.mp4"); | |
var dInfo = new FileInfo(@"D:\Work\Video Editing\Raw\dst.mp4"); | |
if (dInfo.Exists) dInfo.Delete(); | |
var sw = new Stopwatch(); | |
using (var ss = sInfo.OpenRead()) | |
using (var ds = dInfo.OpenWrite()) | |
using (var cs = new FifoStream()) | |
{ | |
sw.Start(); | |
while ((readbytes = ss.Read(buf, 0, buf.Length)) != 0) | |
{ | |
cs.Write(buf, 0, readbytes); | |
while ((crbytes = cs.Read(cBuf, 0, cBuf.Length)) != 0) | |
{ | |
ds.Write(cBuf, 0, crbytes); | |
} | |
} | |
sw.Stop(); | |
} | |
var sHash = sInfo.ToHashBytes<SHA256>(); | |
var dHash = dInfo.ToHashBytes<SHA256>(); | |
Console.WriteLine($"File equality: {sHash.SequenceEqual(dHash)} / {sw.Elapsed.TotalMilliseconds} ms"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment