public void GetCopressionRatioOfFileFilledWith_0_OfAround_200K_GZIP_Test() { int length = 8 * 1024 * 200; //around 200k bits int max = 1000; var dynamicAverage = new BlockingDoubleAverage(); int count = 0; Parallel.For(0, max, i => { Interlocked.Increment(ref count); string fName = String.Concat(r.Next(), "tmp.bin"); var bitArray = new BitArray(length, false); binaryFileWriter.Write(fName, FileMode.OpenOrCreate, bitArray.ToByteArray()); double value = GzipStreamHelper.Compress(fName); dynamicAverage.Add(value); if (count % 100 == 0) { Trace.WriteLine("Processed: " + count); } File.Delete(fName); }); double result = dynamicAverage.GetCurrentAverage(); Trace.WriteLine("Compressed: " + max + "files"); Trace.WriteLine("Lenght of binary data: " + length); Trace.WriteLine("Average compression: " + result); }
public void CompressLineOfOneEventTest() { IEnumerable <int> sequence = rndEventGenerator.GenerateLineOfOneEvent(0, sequenceLenght); tmpFilePath = String.Concat(r.Next(), "tmp.bin"); binaryFileWriter.Write(tmpFilePath, FileMode.CreateNew, sequence); double compressionRate = GzipStreamHelper.Compress(tmpFilePath); Assert.IsTrue(compressionRate > 0); }
public void CompressIntegrationTest() { IEnumerable <int> availableEvents = new[] { 0, 1, 2 }; IEnumerable <int> sequence = rndEventGenerator.GenerateRandomEvents(availableEvents, sequenceLenght); tmpFilePath = String.Concat(r.Next(), "tmp.bin"); binaryFileWriter.Write(tmpFilePath, FileMode.CreateNew, sequence); double compressionRate = GzipStreamHelper.Compress(tmpFilePath); Assert.IsTrue(compressionRate > 0); }