예제 #1
0
        static void SaveSummary(Summary summary)
        {
            var solutionDir = GetSolutionDirectory();

            if (solutionDir is null)
            {
                return;
            }

            var targetType = GetTargetType(summary);

            if (targetType is null)
            {
                return;
            }

            var title = targetType.Name;

            var resultsPath = Path.Combine(solutionDir, "Benchmarks");

            _ = Directory.CreateDirectory(resultsPath);

            var filePath = Path.Combine(resultsPath, $"{title}.md");

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

            using var fileWriter = new StreamWriter(filePath, false, Encoding.UTF8);
            var logger = new StreamLogger(fileWriter);

            logger.WriteLine($"## {title}");
            logger.WriteLine();

            logger.WriteLine("### Source");
            logger.WriteLine($"[{title}.cs](../NetFabric.Hyperlinq.Benchmarks/Benchmarks/{title}.cs)");
            logger.WriteLine();

            logger.WriteLine("### References:");

            var linqVersion = GetInformationalVersion(typeof(Enumerable).Assembly);

            logger.WriteLine($"- Linq: {linqVersion}");

            var linqAsyncVersion = GetInformationalVersion(typeof(AsyncEnumerable).Assembly);

            logger.WriteLine($"- System.Linq.Async: [{linqAsyncVersion}](https://www.nuget.org/packages/System.Linq.Async/{linqAsyncVersion})");

            var interactiveVersion = GetInformationalVersion(typeof(EnumerableEx).Assembly);

            logger.WriteLine($"- System.Interactive: [{interactiveVersion}](https://www.nuget.org/packages/System.Interactive/{interactiveVersion})");

            var interactiveAsyncVersion = GetInformationalVersion(typeof(AsyncEnumerableEx).Assembly);

            logger.WriteLine($"- System.Interactive.Async: [{interactiveAsyncVersion}](https://www.nuget.org/packages/System.Interactive.Async/{interactiveAsyncVersion})");

            var structLinqVersion = GetInformationalVersion(typeof(StructLinq.StructEnumerable).Assembly);

            logger.WriteLine($"- StructLinq: [{structLinqVersion}](https://www.nuget.org/packages/StructLinq/{structLinqVersion})");

            var hyperlinqVersion = GetInformationalVersion(typeof(ValueEnumerable).Assembly);

            logger.WriteLine($"- NetFabric.Hyperlinq: [{hyperlinqVersion}](https://www.nuget.org/packages/NetFabric.Hyperlinq/{hyperlinqVersion})");

            logger.WriteLine();

            logger.WriteLine("### Results:");
            MarkdownExporter.GitHub.ExportToLog(summary, logger);
        }
예제 #2
0
        private static void SaveSummary(Summary summary)
        {
            var solutionDir = GetSolutionDirectory();

            if (solutionDir == null)
            {
                return;
            }

            var title = GetTitle(summary);

            if (title == null)
            {
                return;
            }

            var titleLine = $"## {title}";

            var filePath = Path.Combine(solutionDir, "README.md");

            var prefixLines = new List <string>();
            var suffixLines = new List <string>();

            if (File.Exists(filePath))
            {
                var allLines = File.ReadAllLines(filePath);

                var foundSummary = false;
                var inOldSummary = false;

                foreach (var line in allLines)
                {
                    if (!foundSummary)
                    {
                        if (line == titleLine)
                        {
                            foundSummary = true;
                            inOldSummary = true;
                            continue;
                        }

                        prefixLines.Add(line);
                        continue;
                    }

                    if (inOldSummary)
                    {
                        if (!line.StartsWith("#"))
                        {
                            continue;
                        }

                        inOldSummary = false;
                    }

                    suffixLines.Add(line);
                }
            }

            using (var fileWriter = new StreamWriter(filePath, false, Encoding.UTF8))
            {
                var logger = new StreamLogger(fileWriter);

                foreach (var line in prefixLines)
                {
                    logger.WriteLine(line);
                }

                logger.WriteLineHeader(titleLine);
                logger.WriteLine();

                MarkdownExporter.GitHub.ExportToLog(summary, logger);
                logger.WriteLine();

                foreach (var line in suffixLines)
                {
                    logger.WriteLine(line);
                }
            }
        }
예제 #3
0
        static void SaveSummary(Summary summary)
        {
            var solutionDir = GetSolutionDirectory();

            if (solutionDir is null)
            {
                return;
            }

            var targetType = GetTargetType(summary);

            if (targetType is null)
            {
                return;
            }

            var title      = targetType.Name;
            var pointIndex = targetType.Namespace.IndexOf('.');

            if (pointIndex >= 0)
            {
                title = $"{EndSubstring(targetType.Namespace, pointIndex + 1)}.{targetType.Name}";
            }

            var resultsPath = Path.Combine(solutionDir, "Results");

            _ = Directory.CreateDirectory(resultsPath);

            var filePath = Path.Combine(resultsPath, $"{title}.md");

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

            using var fileWriter = new StreamWriter(filePath, false, Encoding.UTF8);
            var logger = new StreamLogger(fileWriter);

            logger.WriteLine($"## {title}");
            logger.WriteLine();

            logger.WriteLine("### Source");
            var sourceLink = new StringBuilder("../LinqBenchmarks");

            foreach (var folder in targetType.Namespace.Split('.').AsEnumerable().Skip(1))
            {
                _ = sourceLink.Append($"/{folder}");
            }
            _ = sourceLink.Append($"/{targetType.Name}.cs");
            logger.WriteLine($"[{targetType.Name}.cs]({sourceLink})");
            logger.WriteLine();

            logger.WriteLine("### References:");

            var valueLinqVersion = GetInformationalVersion(typeof(Cistern.ValueLinq.Enumerable).Assembly);

            logger.WriteLine($"- Cistern.ValueLinq: [{valueLinqVersion}](https://www.nuget.org/packages/Cistern.ValueLinq/{valueLinqVersion})");

            var linqFasterVersion = GetInformationalVersion(typeof(LinqFaster).Assembly);

            logger.WriteLine($"- JM.LinqFaster: [{linqFasterVersion}](https://www.nuget.org/packages/JM.LinqFaster/{linqFasterVersion})");

            var linqFasterSimdVersion = GetInformationalVersion(typeof(LinqFasterSIMD).Assembly);

            logger.WriteLine($"- LinqFaster.SIMD: [{linqFasterVersion}](https://www.nuget.org/packages/LinqFaster.SIMD/{linqFasterSimdVersion})");

            var linqAfVersion = GetFileVersion(typeof(LinqAF.Enumerable).Assembly);

            logger.WriteLine($"- LinqAF: [{linqAfVersion}](https://www.nuget.org/packages/LinqAF/{linqAfVersion})");

            var structLinqVersion = GetInformationalVersion(typeof(StructLinq.BCL.List.ListEnumerable <>).Assembly);

            logger.WriteLine($"- StructLinq.BCL: [{structLinqVersion}](https://www.nuget.org/packages/StructLinq.BCL/{structLinqVersion})");

            var hyperlinqVersion = GetInformationalVersion(typeof(ValueEnumerable).Assembly);

            logger.WriteLine($"- NetFabric.Hyperlinq: [{hyperlinqVersion}](https://www.nuget.org/packages/NetFabric.Hyperlinq/{hyperlinqVersion})");

            logger.WriteLine();

            logger.WriteLine("### Results:");
            MarkdownExporter.GitHub.ExportToLog(summary, logger);
        }