Example #1
0
 public void Benchmark(BenchmarkContext context)
 {
     Task.WhenAll(AffixFilePaths.Select(async filePath =>
     {
         await AffixReader.ReadFileAsync(filePath).ConfigureAwait(false);
         AffixFilesLoaded.Increment();
     })).Wait();
 }
Example #2
0
        public void Setup(BenchmarkContext context)
        {
            var testAssemblyPath    = Path.GetFullPath(GetType().Assembly.Location);
            var filesDirectory      = Path.Combine(Path.GetDirectoryName(testAssemblyPath), "files/");
            var dictionaryFilePaths = Directory.GetFiles(filesDirectory, "*.dic")
                                      .OrderBy(p => p);

            DictionaryLoadArguments = Task.WhenAll(
                dictionaryFilePaths
                .Select(async dicFilePath =>
            {
                return(new DictionaryLoadData
                {
                    DictionaryFilePath = dicFilePath,
                    Affix = await Task.Run(() => AffixReader.ReadFileAsync(Path.ChangeExtension(dicFilePath, "aff"))).ConfigureAwait(false)
                });
            }))
                                      .Result;

            DictionaryFilesLoaded = context.GetCounter(nameof(DictionaryFilesLoaded));
        }