Exemplo n.º 1
0
 public void TestPerfermence(string path)
 {
     int num;
     byte[] buffer = File.ReadAllBytes(path);
     Stopwatch stopwatch = Stopwatch.StartNew();
     MemoryStream targetStream = new MemoryStream();
     for (num = 0; num < 10; num++)
     {
         targetStream.SetLength(0L);
         Lz4CompressStream stream2 = new Lz4CompressStream(targetStream);
         stream2.Write(buffer, 0, buffer.Length);
         stream2.Close();
     }
     Console.WriteLine("compress total {0} ms, {1}MB/S", stopwatch.ElapsedMilliseconds,
         (buffer.Length * 10 / stopwatch.ElapsedMilliseconds) / 0x400L);
     stopwatch.Restart();
     for (num = 0; num < 10; num++)
     {
         targetStream.Position = 0L;
         Lz4DecompressStream stream3 = new Lz4DecompressStream(targetStream);
         Assert.That(stream3.Read(buffer, 0, buffer.Length), Is.EqualTo(buffer.Length));
     }
     Console.WriteLine("decompress total {0} ms, {1}MB/S", stopwatch.ElapsedMilliseconds,
         (buffer.Length * 10 / stopwatch.ElapsedMilliseconds) / 0x400L);
 }
Exemplo n.º 2
0
 public void TestCompress()
 {
     MemoryStream targetStream = new MemoryStream();
     Lz4CompressStream stream2 = new Lz4CompressStream(targetStream);
     byte[] buffer = new byte[0x100];
     for (int i = 0; i < buffer.Length; i++)
     {
         buffer[i] = (byte)i;
     }
     stream2.Write(buffer, 0, buffer.Length);
     stream2.Close();
     targetStream.Position = 0L;
     Lz4DecompressStream stream3 = new Lz4DecompressStream(targetStream);
     byte[] buffer2 = new byte[buffer.Length];
     Assert.That(stream3.Read(buffer2, 0, buffer2.Length), Is.EqualTo(buffer2.Length));
     Assert.That(buffer2, Is.EquivalentTo(buffer));
 }