private static void RunParallelTest(int level) { byte[] original = File.ReadAllBytes("./Flower.bmp"); byte[] compressedBytes; using (var compressed = new MemoryStream()) { using (var lz = new QuickLZStream(compressed, CompressionMode.Compress, level)) { lz.Write(original, 0, original.Length); } compressedBytes = compressed.ToArray(); } var tasks = new List<Task>(); for (int j = 0; j < 4; j++) { Task task = Factory.StartNew(() => { var result = new byte[original.Length]; for (int k = 0; k < 100; k++) { using (var compressed = new MemoryStream(compressedBytes)) using (var lzd = new QuickLZStream(compressed, CompressionMode.Decompress, level)) { lzd.Read(result, 0, result.Length); } } }); tasks.Add(task); } Task.WaitAll(tasks.ToArray()); }
private static void RunParallelTest(int level) { byte[] original = File.ReadAllBytes("./Flower.bmp"); byte[] compressedBytes; using (var compressed = new MemoryStream()) { using (var lz = new QuickLZStream(compressed, CompressionMode.Compress, level)) { lz.Write(original, 0, original.Length); } compressedBytes = compressed.ToArray(); } var tasks = new List <Task>(); for (int j = 0; j < 4; j++) { Task task = Factory.StartNew(() => { var result = new byte[original.Length]; for (int k = 0; k < 100; k++) { using (var compressed = new MemoryStream(compressedBytes)) using (var lzd = new QuickLZStream(compressed, CompressionMode.Decompress, level)) { lzd.Read(result, 0, result.Length); } } }); tasks.Add(task); } Task.WaitAll(tasks.ToArray()); }
private static void RunGeneralTest(int level) { byte[] original = File.ReadAllBytes("./Flower.bmp"); byte[] compressedBytes; using (var compressed = new MemoryStream()) { using (var lz = new QuickLZStream(compressed, CompressionMode.Compress, level)) { lz.Write(original, 0, original.Length); } compressedBytes = compressed.ToArray(); } var result = new byte[original.Length]; using (var compressed = new MemoryStream(compressedBytes)) { using (var lzd = new QuickLZStream(compressed, CompressionMode.Decompress, level)) { lzd.Read(result, 0, result.Length); } } for (int i = 0; i < original.Length; i++) { Assert.AreEqual(original[i], result[i]); } }