private const int MAXIMUM_LENGTH = 1 * 10 * 1024 * 1024; // 10MB #endregion #region utilities private void TestConformance(TimedMethod[] compressors, TimedMethod[] decompressors) { var provider = new BlockDataProvider(Utilities.GetSilesiaCorpusFolder()); var r = new Random(0); Console.WriteLine("Architecture: {0}bit", IntPtr.Size * 8); var total = 0; const long limit = 1L * 1024 * 1024 * 1024; var last_pct = 0; while (total < limit) { var length = Utilities.RandomLength(r, MAXIMUM_LENGTH); var block = provider.GetBytes(length); TestData(block, compressors, decompressors); total += block.Length; var pct = (int)((double)total * 100 / limit); if (pct > last_pct) { Console.WriteLine("{0}%...", pct); last_pct = pct; } } }
// ReSharper disable InconsistentNaming private static void DoAction(Action <byte[], Stream> action, bool read) { var provider = new BlockDataProvider(Utilities.GetSilesiaCorpusFolder()); var r = new Random(0); Console.WriteLine("Architecture: {0}bit", IntPtr.Size * 8); Console.WriteLine("CodecName: {0}", LZ4Codec.CodecName); var fileName = Path.Combine(Path.GetTempPath(), "BlockCompressionStream.dat"); using (var stream = new LZ4Stream( read ? File.OpenRead(fileName) : File.Create(fileName), read ? CompressionMode.Decompress : CompressionMode.Compress, LZ4StreamFlags.HighCompression)) { var total = 0; const long limit = TOTAL_SIZE; var last_pct = 0; while (total < limit) { var length = Utilities.RandomLength(r, CHUNK_SIZE); var block = provider.GetBytes(length); action(block, stream); total += block.Length; var pct = (int)((double)total * 100 / limit); if (pct > last_pct) { Console.WriteLine("{0}%...", pct); last_pct = pct; } } } }
public Disk(object readLock, object writeLock, BlockDataProvider readProvider, BlockDataProvider writeProvider, Queue <ByteBlock> readQueue, Queue <ByteBlock> writeQueue, int queueCapacity, ref AutoResetEvent resetEvent, Compression.Enums.CompressionAlgorithms algorithms, Compression.Enums.CompressionType CompressionType) : base(readLock, writeLock, writeQueue, readQueue) { this.queueCapacity = queueCapacity; this.readProvider = readProvider; this.writeProvider = writeProvider; this.waitHandle = resetEvent; this.algorithms = algorithms; this.CompressionType = CompressionType; }