From 52671f0252a7b0eb7825036ebd659edc5edd4dbc Mon Sep 17 00:00:00 2001 From: "Matthew Parker [SSW]" <61717342+MattParkerDev@users.noreply.github.com> Date: Sat, 11 Jan 2025 13:26:04 +1000 Subject: [PATCH] Add benchmarks project --- SharpIDE.Photino.sln | 9 +++++ .../Features/SolutionDiscovery/RoslynTest.cs | 34 +++++++++---------- .../Components/SolutionExplorer.razor | 1 + src/SharpIDE.Photino/Pages/Home.razor | 1 + .../MSBuildWorkspaceBenchmarks.cs | 19 +++++++++++ tests/Roslyn.Benchmarks/Program.cs | 4 +++ .../Roslyn.Benchmarks.csproj | 16 +++++++++ 7 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 tests/Roslyn.Benchmarks/MSBuildWorkspaceBenchmarks.cs create mode 100644 tests/Roslyn.Benchmarks/Program.cs create mode 100644 tests/Roslyn.Benchmarks/Roslyn.Benchmarks.csproj diff --git a/SharpIDE.Photino.sln b/SharpIDE.Photino.sln index 6989e79..10b9985 100644 --- a/SharpIDE.Photino.sln +++ b/SharpIDE.Photino.sln @@ -18,6 +18,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpIDE.Photino", "src\Sha EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpIDE.Application", "src\SharpIDE.Application\SharpIDE.Application.csproj", "{D7D5D39E-DA3A-4B10-8F40-B07B769347F4}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{B6835010-35FA-4C74-AB48-009FB923185D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Roslyn.Benchmarks", "tests\Roslyn.Benchmarks\Roslyn.Benchmarks.csproj", "{252CE098-2F9A-4DA3-A172-EE1167B335BF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -35,9 +39,14 @@ Global {D7D5D39E-DA3A-4B10-8F40-B07B769347F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {D7D5D39E-DA3A-4B10-8F40-B07B769347F4}.Release|Any CPU.ActiveCfg = Release|Any CPU {D7D5D39E-DA3A-4B10-8F40-B07B769347F4}.Release|Any CPU.Build.0 = Release|Any CPU + {252CE098-2F9A-4DA3-A172-EE1167B335BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {252CE098-2F9A-4DA3-A172-EE1167B335BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {252CE098-2F9A-4DA3-A172-EE1167B335BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {252CE098-2F9A-4DA3-A172-EE1167B335BF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {E35167E1-0FF4-4194-97A8-CC95EDA224CD} = {F4ED837F-888A-4D01-BCED-C360B9CE0865} {D7D5D39E-DA3A-4B10-8F40-B07B769347F4} = {F4ED837F-888A-4D01-BCED-C360B9CE0865} + {252CE098-2F9A-4DA3-A172-EE1167B335BF} = {B6835010-35FA-4C74-AB48-009FB923185D} EndGlobalSection EndGlobal diff --git a/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs b/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs index e26e49a..dd332b0 100644 --- a/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs +++ b/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs @@ -18,23 +18,23 @@ public static class RoslynTest Console.WriteLine($"Solution loaded in {timer.ElapsedMilliseconds}ms"); Console.WriteLine(); - foreach (var project in solution.Projects) - { - Console.WriteLine($"Project: {project.Name}"); - foreach (var document in project.Documents) - { - Console.WriteLine($"Document: {document.Name}"); - var syntaxTree = await document.GetSyntaxTreeAsync(); - var root = await syntaxTree!.GetRootAsync(); - var classifiedSpans = await Classifier.GetClassifiedSpansAsync(document, root.FullSpan); - foreach (var span in classifiedSpans) - { - var classifiedSpan = root.GetText().GetSubText(span.TextSpan); - Console.WriteLine($"{span.TextSpan}: {span.ClassificationType}"); - Console.WriteLine(classifiedSpan); - } - } - } + // foreach (var project in solution.Projects) + // { + // Console.WriteLine($"Project: {project.Name}"); + // foreach (var document in project.Documents) + // { + // Console.WriteLine($"Document: {document.Name}"); + // var syntaxTree = await document.GetSyntaxTreeAsync(); + // var root = await syntaxTree!.GetRootAsync(); + // var classifiedSpans = await Classifier.GetClassifiedSpansAsync(document, root.FullSpan); + // foreach (var span in classifiedSpans) + // { + // var classifiedSpan = root.GetText().GetSubText(span.TextSpan); + // Console.WriteLine($"{span.TextSpan}: {span.ClassificationType}"); + // Console.WriteLine(classifiedSpan); + // } + // } + // } } } diff --git a/src/SharpIDE.Photino/Components/SolutionExplorer.razor b/src/SharpIDE.Photino/Components/SolutionExplorer.razor index 4e28426..6d43b55 100644 --- a/src/SharpIDE.Photino/Components/SolutionExplorer.razor +++ b/src/SharpIDE.Photino/Components/SolutionExplorer.razor @@ -58,6 +58,7 @@ private void LoadSolution(string solutionPath) { + return; var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath("C:/Users/Matthew/Documents/Git/amazon/ClientPortal.sln"); ArgumentNullException.ThrowIfNull(solutionFile); _solutionFile = solutionFile; diff --git a/src/SharpIDE.Photino/Pages/Home.razor b/src/SharpIDE.Photino/Pages/Home.razor index 6413d90..38aadb3 100644 --- a/src/SharpIDE.Photino/Pages/Home.razor +++ b/src/SharpIDE.Photino/Pages/Home.razor @@ -7,6 +7,7 @@ { protected override async Task OnInitializedAsync() { + await Task.Delay(100); await RoslynTest.Analyse("C:/Users/Matthew/Documents/Git/StatusApp/StatusApp.sln"); } } diff --git a/tests/Roslyn.Benchmarks/MSBuildWorkspaceBenchmarks.cs b/tests/Roslyn.Benchmarks/MSBuildWorkspaceBenchmarks.cs new file mode 100644 index 0000000..c4e02f0 --- /dev/null +++ b/tests/Roslyn.Benchmarks/MSBuildWorkspaceBenchmarks.cs @@ -0,0 +1,19 @@ +using System.Diagnostics; +using BenchmarkDotNet.Attributes; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.MSBuild; + +namespace Roslyn.Benchmarks; + +public class MSBuildWorkspaceBenchmarks +{ + private const string _solutionFilePath = "C:/Users/Matthew/Documents/Git/StatusApp/StatusApp.sln"; + + [Benchmark] + public async Task ParseSolutionFileFromPath() + { + var workspace = MSBuildWorkspace.Create(); + var solution = await workspace.OpenSolutionAsync(_solutionFilePath); + return solution; + } +} diff --git a/tests/Roslyn.Benchmarks/Program.cs b/tests/Roslyn.Benchmarks/Program.cs new file mode 100644 index 0000000..36f4a10 --- /dev/null +++ b/tests/Roslyn.Benchmarks/Program.cs @@ -0,0 +1,4 @@ +using BenchmarkDotNet.Running; +using Roslyn.Benchmarks; + +BenchmarkRunner.Run(); diff --git a/tests/Roslyn.Benchmarks/Roslyn.Benchmarks.csproj b/tests/Roslyn.Benchmarks/Roslyn.Benchmarks.csproj new file mode 100644 index 0000000..c2ed198 --- /dev/null +++ b/tests/Roslyn.Benchmarks/Roslyn.Benchmarks.csproj @@ -0,0 +1,16 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + + +