Ejemplo n.º 1
0
        private static void Run(string resultsFile, string path, long limit, string codec, string architecture)
        {
            var         provider = new FileDataProvider(path.Split(';'));
            TimedMethod compressor;
            TimedMethod decompressor;

            var codecCode = SelectCodec(codec, architecture, out compressor, out decompressor);

            Warmup(compressor, decompressor);

            long total = 0;
            var  pct   = 0;

            while (total < limit)
            {
                var original     = provider.GetBytes();
                var length       = original.Length;
                var compressed   = compressor.Run(original, length);
                var decompressed = decompressor.Run(compressed, length);
                AssertEqual(original, decompressed);
                total += length;

                var new_pct = (int)(total * 100 / limit);
                if (new_pct > pct)
                {
                    Console.WriteLine("{0}%", new_pct);
                    pct = new_pct;
                }
            }

            Console.WriteLine("{0}: {1:0.00} / {2:0.00}", codecCode, compressor.Speed, decompressor.Speed);

            UpdateResults(resultsFile, codecCode, compressor, decompressor);
        }
Ejemplo n.º 2
0
        private static void TestPerformance(TimedMethod[] compressors, TimedMethod[] decompressors)
        {
            var names = compressors.Select(c => c.Name).ToArray();

            foreach (var name in names)
            {
                var compressor   = compressors.First(c => c.Name == name);
                var decompressor = decompressors.First(d => d.Name == name);

                Console.WriteLine("---- {0} ----", name);

                Warmup(compressor, decompressor);

                var        provider = new FileDataProvider(Utilities.GetSilesiaCorpusFolder());
                long       total    = 0;
                const long limit    = 1L * 1024 * 1024 * 1024;
                var        last_pct = 0;

                while (total < limit)
                {
                    var block = provider.GetBytes();
                    TestSpeed(block, compressor, decompressor);
                    total += block.Length;
                    var pct = (int)((double)total * 100 / limit);
                    if (pct > last_pct)
                    {
                        Console.WriteLine("{0}%...", pct);
                        last_pct = pct;
                    }
                }

                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                Thread.Sleep(1000);
            }

            Console.WriteLine("---- Results ----");

            Console.WriteLine("Architecture: {0}bit", IntPtr.Size * 8);
            Console.WriteLine("Compression:");
            foreach (var compressor in compressors)
            {
                Console.WriteLine("  {0}: {1:0.00}MB/s ({2:0.00}%)", compressor.Name, compressor.Speed, compressor.Ratio);
            }

            Console.WriteLine("Decompression:");
            foreach (var decompressor in decompressors)
            {
                Console.WriteLine("  {0}: {1:0.00}MB/s", decompressor.Name, decompressor.Speed);
            }
        }