Ejemplo n.º 1
0
        private async Task SaveAggregation(IReadOnlyCollection <Aggregation> aggregations,
                                           ArrayGenerationType generationType, TypeCode type)
        {
            var filePath = Path.Combine(_settings.DestinationFolderPath, generationType.ToString(), $"{type}.csv");

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            Directory.CreateDirectory(Path.GetDirectoryName(filePath));

            await using var writer    = new StreamWriter(filePath);
            await using var csvWriter = new CsvWriter(writer, CultureInfo.InvariantCulture);

            csvWriter.WriteField("SorterName");
            foreach (var length in _settings.CollectionsLength.OrderBy(length => length))
            {
                csvWriter.WriteField(length);
            }
            await csvWriter.NextRecordAsync();

            foreach (var aggregation in aggregations)
            {
                csvWriter.WriteField(aggregation.SorterName);
                foreach (var elapsed in aggregation.ElapsedTimes.Values)
                {
                    csvWriter.WriteField(elapsed.TotalMilliseconds);
                }

                await csvWriter.NextRecordAsync();
            }
        }
Ejemplo n.º 2
0
 public Func <int, T[]> GetGenerationMethod <T>(ArrayGenerationType type) => type switch
 {