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


C# PerfUtils.GetTestFilePath方法代码示例

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


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

示例1: CompressedFiles

        /// <summary>
        /// Yields an Enumerable list of paths to GZTestData files
        /// </summary>
        public static IEnumerable<object[]> CompressedFiles()
        {
            if (_compressedFiles == null)
            {
                PerfUtils utils = new PerfUtils();
                _compressedFiles = new List<object[]>();
                // Crypto random data
                byte[] bytes = new byte[100000000];
                var rand = RandomNumberGenerator.Create();
                rand.GetBytes(bytes);
                string filePath = utils.GetTestFilePath() + ".gz";
                using (FileStream output = File.Create(filePath))
                using (GZipStream zip = new GZipStream(output, CompressionMode.Compress))
                    zip.Write(bytes, 0, bytes.Length);
                _compressedFiles.Add(new object[] { filePath });

                // Create a compressed file with repeated segments
                bytes = Text.Encoding.UTF8.GetBytes(utils.CreateString(100000));
                filePath = utils.GetTestFilePath() + ".gz";
                using (FileStream output = File.Create(filePath))
                using (GZipStream zip = new GZipStream(output, CompressionMode.Compress))
                    for (int i = 0; i < 1000; i++)
                        zip.Write(bytes, 0, bytes.Length);
                _compressedFiles.Add(new object[] { filePath });
            }
            return _compressedFiles;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:30,代码来源:Perf.DeflateStream.cs

示例2: Compress_Canterbury

 public void Compress_Canterbury(int innerIterations, string fileName, CompressionLevel compressLevel)
 {
     byte[] bytes = File.ReadAllBytes(Path.Combine("GZTestData", "Canterbury", fileName));
     PerfUtils utils = new PerfUtils();
     FileStream[] filestreams = new FileStream[innerIterations];
     GZipStream[] gzips = new GZipStream[innerIterations];
     string[] paths = new string[innerIterations];
     foreach (var iteration in Benchmark.Iterations)
     {
         for (int i = 0; i < innerIterations; i++)
         {
             paths[i] = utils.GetTestFilePath();
             filestreams[i] = File.Create(paths[i]);
         }
         using (iteration.StartMeasurement())
             for (int i = 0; i < innerIterations; i++)
             {
                 gzips[i] = new GZipStream(filestreams[i], compressLevel);
                 gzips[i].Write(bytes, 0, bytes.Length);
                 gzips[i].Flush();
                 gzips[i].Dispose();
                 filestreams[i].Dispose();
             }
         for (int i = 0; i < innerIterations; i++)
             File.Delete(paths[i]);
     }
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:27,代码来源:Perf.GZipStream.cs

示例3: GetDirectoryName

 public void GetDirectoryName()
 {
     PerfUtils utils = new PerfUtils();
     string testPath = utils.GetTestFilePath();
     foreach (var iteration in Benchmark.Iterations)
         using (iteration.StartMeasurement())
             for (int i = 0; i < 20000; i++)
             {
                 Path.GetDirectoryName(testPath); Path.GetDirectoryName(testPath); Path.GetDirectoryName(testPath);
                 Path.GetDirectoryName(testPath); Path.GetDirectoryName(testPath); Path.GetDirectoryName(testPath);
                 Path.GetDirectoryName(testPath); Path.GetDirectoryName(testPath); Path.GetDirectoryName(testPath);
             }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:Perf.Path.cs

示例4: Combine

        public void Combine(int innerIterations)
        {
            PerfUtils utils = new PerfUtils();
            string testPath1 = utils.GetTestFilePath();
            string testPath2 = utils.CreateString(10);

            foreach (var iteration in Benchmark.Iterations)
                using (iteration.StartMeasurement())
                    for (int i = 0; i < innerIterations; i++)
                    {
                        Path.Combine(testPath1, testPath2); Path.Combine(testPath1, testPath2); Path.Combine(testPath1, testPath2);
                        Path.Combine(testPath1, testPath2); Path.Combine(testPath1, testPath2); Path.Combine(testPath1, testPath2);
                        Path.Combine(testPath1, testPath2); Path.Combine(testPath1, testPath2); Path.Combine(testPath1, testPath2);
                    }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:15,代码来源:Perf.Path.cs

示例5: CreateCompressedFile

 /// <returns></returns>
 private static string CreateCompressedFile(CompressionType type)
 {
     const int fileSize = 100000000;
     PerfUtils utils = new PerfUtils();
     string filePath = utils.GetTestFilePath() + ".gz";
     switch (type)
     {    
         case CompressionType.CryptoRandom:
             using (RandomNumberGenerator rand = RandomNumberGenerator.Create())
             {
                 byte[] bytes = new byte[fileSize];
                 rand.GetBytes(bytes);
                 using (FileStream output = File.Create(filePath))
                 using (GZipStream zip = new GZipStream(output, CompressionMode.Compress))
                     zip.Write(bytes, 0, bytes.Length);
             }
             break;
         case CompressionType.RepeatedSegments:
             {
                 byte[] bytes = new byte[fileSize / 1000];
                 new Random(128453).NextBytes(bytes);
                 using (FileStream output = File.Create(filePath))
                 using (GZipStream zip = new GZipStream(output, CompressionMode.Compress))
                     for (int i = 0; i < 1000; i++)
                         zip.Write(bytes, 0, bytes.Length);
             }
             break;
         case CompressionType.NormalData:
             {
                 byte[] bytes = new byte[fileSize];
                 new Random(128453).NextBytes(bytes);
                 using (FileStream output = File.Create(filePath))
                 using (GZipStream zip = new GZipStream(output, CompressionMode.Compress))
                     zip.Write(bytes, 0, bytes.Length);
             }
             break;
     }
     return filePath;
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:40,代码来源:Perf.DeflateStream.cs

示例6: Compress

 public void Compress(CompressionType type)
 {
     byte[] bytes = CreateBytesToCompress(type);
     PerfUtils utils = new PerfUtils();
     foreach (var iteration in Benchmark.Iterations)
     {
         string filePath = utils.GetTestFilePath();
         using (FileStream output = File.Create(filePath))
         using (DeflateStream zip = new DeflateStream(output, CompressionMode.Compress))
         using (iteration.StartMeasurement())
         {
             zip.Write(bytes, 0, bytes.Length);
         }
         File.Delete(filePath);
     }
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:16,代码来源:Perf.DeflateStream.cs


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