Skip to content

Instantly share code, notes, and snippets.

@JKamsker
Created October 19, 2017 21:32
Show Gist options
  • Save JKamsker/4ce64ee099c1adb7dd3a2a087e1c9711 to your computer and use it in GitHub Desktop.
Save JKamsker/4ce64ee099c1adb7dd3a2a087e1c9711 to your computer and use it in GitHub Desktop.
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