public void ResultConsistency(string text, int offset) { var bytes = Encoding.ASCII.GetBytes(text); var crc1 = Crc32CAlgorithm.Append(123456789, bytes, offset, bytes.Length - offset); CoreSwitchHelper.SetCoreAlgType("Crc32C.SafeProxy"); var crc2 = Crc32CAlgorithm.Append(123456789, bytes, offset, bytes.Length - offset); Assert.That(crc2, Is.EqualTo(crc1)); }
public void ResultConsistencyLong() { var bytes = new byte[30000]; new Random().NextBytes(bytes); var crc1 = Crc32CAlgorithm.Append(123456789, bytes, 0, bytes.Length); CoreSwitchHelper.SetCoreAlgType("Crc32C.SafeProxy"); var crc2 = Crc32CAlgorithm.Append(123456789, bytes, 0, bytes.Length); Assert.That(crc2, Is.EqualTo(crc1)); }
public void ThroughputSafe() { CoreSwitchHelper.SetCoreAlgType("Crc32C.SafeProxy"); var data = new byte[65536]; var random = new Random(); random.NextBytes(data); long total = 0; var stopwatch = new Stopwatch(); uint crc = 0; stopwatch.Start(); while (stopwatch.Elapsed < TimeSpan.FromSeconds(3)) { var length = random.Next(data.Length + 1); var offset = random.Next(data.Length - length); crc = Crc32CAlgorithm.Append(crc, data, offset, length); total += length; } stopwatch.Stop(); Console.WriteLine("Throughput: {0:0.0} MB/s", total / stopwatch.Elapsed.TotalSeconds / 1024 / 1024); }
public void TearDown() { CoreSwitchHelper.SetCoreAlg(_defaultCoreAlg); }
public void SetUp() { _defaultCoreAlg = CoreSwitchHelper.GetCoreAlg(); }