当前位置: 首页>>代码示例>>C#>>正文


C# ICompressor.GetType方法代码示例

本文整理汇总了C#中ICompressor.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ICompressor.GetType方法的具体用法?C# ICompressor.GetType怎么用?C# ICompressor.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICompressor的用法示例。


在下文中一共展示了ICompressor.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Performance

        public void Performance(ICompressor compressor)
        {
            results.Add("---------" + compressor.GetType() + "---------");
            byte[] indata = Encoding.UTF8.GetBytes(testData);

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            byte[] result = null;
            foreach (var i in Enumerable.Range(0,100))
            {
                result = compressor.Compress(indata);
            }
            stopwatch.Stop();
            long ticks = stopwatch.ElapsedTicks;
            results.Add("Compress: " +  ticks);

            stopwatch.Reset();
            stopwatch.Start();

            byte[] resurrected;
            foreach (var i in Enumerable.Range(0, 100))
            {
                resurrected = compressor.Decompress(result);
            }
            stopwatch.Stop();
            ticks = stopwatch.ElapsedTicks;
            results.Add("Decompress: " + ticks);
            results.Add("Compression: " + result.Length / (1.0 * indata.Length));
        }
开发者ID:NerdPad,项目名称:OrigoDB,代码行数:29,代码来源:CompressorTests.cs

示例2: UploadFileWithCompress

        public static MongoGridFSFileInfo UploadFileWithCompress(this IMongoRepository repository, ICompressor compressor, byte[] data,
                                                                 string remoteFilename) {
            compressor.ShouldNotBeNull("compressor");

            var entry = new CompressedFileItem(compressor.GetType(), compressor.Compress(data));

            using(var stream = new MemoryStream(FileSerializer.Serialize(entry))) {
                return repository.UploadFile(remoteFilename, stream);
            }
        }
开发者ID:debop,项目名称:NFramework,代码行数:10,代码来源:MongoTool.GridFS.cs

示例3: Benchmark

        private void Benchmark(ICompressor compressor)
        {
            Console.WriteLine("Target compression ratio: {0:P1}", _dataCreator.CompressionRatio);
            Console.WriteLine();

            const int batch = 10;
            Console.WriteLine("Benchmark of {0}:", compressor.GetType().Name);
            WarmUpCompressor(compressor);
            DoBenchmark(compressor, 4 * 1024, batch);
            DoBenchmark(compressor, 32 * 1024, batch);
            DoBenchmark(compressor, 64 * 1024, batch);
            DoBenchmark(compressor, 128 * 1024, batch);
            DoBenchmark(compressor, 256 * 1024, batch);
            DoBenchmark(compressor, 512 * 1024, batch);
            DoBenchmark(compressor, 1024 * 1024, batch);
            DoBenchmark(compressor, 2048 * 1024, batch);
            DoBenchmark(compressor, 5120 * 1024, batch);
            DoBenchmark(compressor, 10240 * 1024, batch);
            DoBenchmark(compressor, 20480 * 1024, batch);
            Console.WriteLine("---------------------------------------------");
        }
开发者ID:tyaloo,项目名称:snappydotnet,代码行数:21,代码来源:CompressorTest.cs


注:本文中的ICompressor.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。