Exemple #1
0
        public void SetCompression(string level)
        {
            if (string.IsNullOrWhiteSpace(level))
            {
                compressionLevel = CompressionLevel.Optimal;
            }
            else if (level.Equals("none", StringComparison.CurrentCultureIgnoreCase))
            {
                compressionLevel = CompressionLevel.NoCompression;
            }
            else if (level.Equals("fast", StringComparison.CurrentCultureIgnoreCase))
            {
                compressionLevel = CompressionLevel.Fastest;
            }
            else
            {
                compressionLevel = CompressionLevel.Optimal;
            }

            commandOutputProvider.Information($"Setting Zip compression level to {compressionLevel.ToString()}");
        }
Exemple #2
0
        public void SetCompression(PackageCompressionLevel level)
        {
            switch (level)
            {
            case PackageCompressionLevel.None:
                compressionLevel = CompressionLevel.NoCompression;
                break;

            case PackageCompressionLevel.Fast:
                compressionLevel = CompressionLevel.Fastest;
                break;

            case PackageCompressionLevel.Optimal:
                compressionLevel = CompressionLevel.Optimal;
                break;

            default:
                throw new CommandException($"Unexpected compression value `{level}'. Valid values are {Enum.GetNames(typeof(PackageCompressionLevel)).ReadableJoin()}.");
            }

            commandOutputProvider.Information($"Setting Zip compression level to {compressionLevel.ToString()}");
        }
Exemple #3
0
        public void Decompress_Canterbury(int innerIterations, string folder, string fileName, CompressionLevel level)
        {
            string zipFilePath    = Path.Combine("BrotliTestData", folder, "BrotliCompressed", fileName + level.ToString() + ".br");
            string sourceFilePath = Path.Combine("BrotliTestData", folder, fileName);

            byte[]         outputRead = new byte[new FileInfo(sourceFilePath).Length];
            MemoryStream[] memories   = new MemoryStream[innerIterations];
            foreach (var iteration in Benchmark.Iterations)
            {
                for (int i = 0; i < innerIterations; i++)
                {
                    memories[i] = new MemoryStream(File.ReadAllBytes(zipFilePath));
                }

                using (iteration.StartMeasurement())
                    for (int i = 0; i < innerIterations; i++)
                    {
                        using (BrotliStream decompressBrotli = new BrotliStream(memories[i], CompressionMode.Decompress))
                            decompressBrotli.Read(outputRead, 0, outputRead.Length);
                    }

                for (int i = 0; i < innerIterations; i++)
                {
                    memories[i].Dispose();
                }
            }
        }
Exemple #4
0
 private Compression(CompressionMethod method, CompressionLevel level)
 {
     _value = method.ToString() + "/" + level.ToString();
 }