public void PartitionFile(string logfileName) { long partitionSize = 1024 * 1024; var logPath = TestDataHelper.GetResourcePath(logfileName); string rootLogDirectory = TestDataHelper.GetDataDirectory(); LogFileContext context = new LogFileContext(logPath, rootLogDirectory); FilePartitioner partitioner = new FilePartitioner(context, partitionSize); var partitions = partitioner.PartitionFile(); partitions.Count.Should().Be(5); }
public void HugeFile() { var compressedExtension = ".gzt"; var decompressedExtension = ".1"; var performance = new PerformanceCounter("Memory", "Available MBytes"); var memory = (long)performance.NextValue(); var size = memory * 2 * MB; Debug.WriteLine($"Generating file with size {size/MB} MB."); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), $"{Path.GetTempPath()}\\gzip\\huge.txt"); GenerateRandomFile(path, size); var compressor = new Compressor(path, FilePartitioner.GetRecommendedChunkSize(path), path + compressedExtension); var decompressor = new Decompressor(path + compressedExtension, path + decompressedExtension); Debug.WriteLine($"Compressing..."); compressor.Compress(); Debug.WriteLine($"Decompressing..."); decompressor.Decompress(); Debug.WriteLine($"Comparing..."); Assert.AreEqual(new FileInfo(path).Length, new FileInfo(path + decompressedExtension).Length); }
public void GetRecommendedPartitionSize(string fileName) { string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), $"Resources\\{fileName}"); Assert.AreEqual(new FileInfo(path).Length / Environment.ProcessorCount, FilePartitioner.GetRecommendedChunkSize(path)); }
public void CalculateChunks(string fileName, int maxPartitionSize, int chunksCount) { string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), $"Resources\\{fileName}"); Assert.AreEqual(chunksCount, FilePartitioner.CalculateChunks(path, maxPartitionSize).Count); }