Beispiel #1
0
        private static void CompressionTestRunner()
        {
            var originalText = TextGenerator.LoremIpsum(1000000, 1000000, 1, 1, 1);
            var compressionTester = new CompressionTester();

            var compressionTimer = new Stopwatch();
            compressionTimer.Start();
            var compressedText = compressionTester.Compress(originalText);
            compressionTimer.Stop();

            var decompressionTimer = new Stopwatch();
            decompressionTimer.Start();

            var decompressedText = compressionTester.Decompress(compressedText);
            decompressionTimer.Stop();

            var originalTextLength = originalText.Length;
            var improvementInLength = originalTextLength - compressedText.Length;

            Console.WriteLine("Original text ({0} characters)", originalTextLength);
            Console.WriteLine();
            Console.WriteLine("Compressed text ({0} characters) [improvement by {1} characters / {2} % ]", compressedText.Length,
                improvementInLength,
                decimal.Round((100 * ((decimal)improvementInLength) / originalTextLength), 0, MidpointRounding.AwayFromZero));

            Console.WriteLine();
            Console.WriteLine("Decompressed text ({0} characters)", decompressedText.Length);

            Console.WriteLine();
            Console.WriteLine(originalText.Equals(decompressedText) ? "Orginal text EQUALS decompressed text" : "Fail");

            Console.WriteLine("Compression took {0} ms.", compressionTimer.ElapsedMilliseconds);
            Console.WriteLine("Decompression took {0} ms.", decompressionTimer.ElapsedMilliseconds);
        }
Beispiel #2
0
        private static void CompressionTestRunner()
        {
            var originalText      = TextGenerator.LoremIpsum(1000000, 1000000, 1, 1, 1);
            var compressionTester = new CompressionTester();

            var compressionTimer = new Stopwatch();

            compressionTimer.Start();
            var compressedText = compressionTester.Compress(originalText);

            compressionTimer.Stop();

            var decompressionTimer = new Stopwatch();

            decompressionTimer.Start();

            var decompressedText = compressionTester.Decompress(compressedText);

            decompressionTimer.Stop();

            var originalTextLength  = originalText.Length;
            var improvementInLength = originalTextLength - compressedText.Length;

            Console.WriteLine("Original text ({0} characters)", originalTextLength);
            Console.WriteLine();
            Console.WriteLine("Compressed text ({0} characters) [improvement by {1} characters / {2} % ]", compressedText.Length,
                              improvementInLength,
                              decimal.Round((100 * ((decimal)improvementInLength) / originalTextLength), 0, MidpointRounding.AwayFromZero));

            Console.WriteLine();
            Console.WriteLine("Decompressed text ({0} characters)", decompressedText.Length);

            Console.WriteLine();
            Console.WriteLine(originalText.Equals(decompressedText) ? "Orginal text EQUALS decompressed text" : "Fail");

            Console.WriteLine("Compression took {0} ms.", compressionTimer.ElapsedMilliseconds);
            Console.WriteLine("Decompression took {0} ms.", decompressionTimer.ElapsedMilliseconds);
        }