rearrange

This commit is contained in:
Matthew Parker [SSW]
2025-01-11 13:46:37 +10:00
parent 822e9e28ae
commit 52e1f33193
7 changed files with 39 additions and 19 deletions

View File

@@ -0,0 +1,11 @@
using Microsoft.CodeAnalysis.MSBuild;
namespace SharpIDE.Application.Features.SolutionDiscovery;
public class Progress : IProgress<ProjectLoadProgress>
{
public void Report(ProjectLoadProgress value)
{
Console.WriteLine($"{value.Operation} completed for {value.FilePath} ({value.TargetFramework}) in {value.ElapsedTime.TotalMilliseconds}ms");
}
}

View File

@@ -9,11 +9,9 @@ public static class RoslynTest
{ {
public static async Task Analyse(string solutionFilePath) public static async Task Analyse(string solutionFilePath)
{ {
var workspace = MSBuildWorkspace.Create(); var workspace = MSBuildWorkspace.Create();
var timer = Stopwatch.StartNew(); var timer = Stopwatch.StartNew();
var solution = await workspace.OpenSolutionAsync(solutionFilePath); var solution = await workspace.OpenSolutionAsync(solutionFilePath, new Progress());
timer.Stop(); timer.Stop();
Console.WriteLine($"Solution loaded in {timer.ElapsedMilliseconds}ms"); Console.WriteLine($"Solution loaded in {timer.ElapsedMilliseconds}ms");
Console.WriteLine(); Console.WriteLine();

View File

@@ -8,6 +8,6 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
await Task.Delay(100); await Task.Delay(100);
await RoslynTest.Analyse("C:/Users/Matthew/Documents/Git/StatusApp/StatusApp.sln"); await RoslynTest.Analyse("C:/Users/Matthew/Documents/Git/amazon/ClientPortal.sln");
} }
} }

View File

@@ -22,7 +22,7 @@ public class Program
app.MainWindow app.MainWindow
.SetSize(1400, 800) .SetSize(1400, 800)
.SetDevToolsEnabled(true) .SetDevToolsEnabled(true)
.SetMaximized(true) //.SetMaximized(true)
.SetLogVerbosity(0) .SetLogVerbosity(0)
//.SetIconFile("favicon.ico") //.SetIconFile("favicon.ico")
.SetTitle("SharpIDE.Photino"); .SetTitle("SharpIDE.Photino");

View File

@@ -1,14 +1,10 @@
using System.Diagnostics; using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild; using Microsoft.CodeAnalysis.MSBuild;
namespace Roslyn.Benchmarks; namespace Roslyn.Benchmarks;
public class MSBuildWorkspaceBenchmarks public class CreateWorkspaceBenchmarks
{ {
private const string _solutionFilePath = "C:/Users/Matthew/Documents/Git/StatusApp/StatusApp.sln";
// | Method | Mean | Error | StdDev | // | Method | Mean | Error | StdDev |
// |-------------------------- |---------:|---------:|---------:| // |-------------------------- |---------:|---------:|---------:|
// | CreateWorkspaceNoParams | 10.88 us | 0.045 us | 0.042 us | // | CreateWorkspaceNoParams | 10.88 us | 0.045 us | 0.042 us |
@@ -32,11 +28,4 @@ public class MSBuildWorkspaceBenchmarks
return workspace; return workspace;
} }
// [Benchmark]
// public async Task<Solution> ParseSolutionFileFromPath()
// {
// var workspace = MSBuildWorkspace.Create();
// var solution = await workspace.OpenSolutionAsync(_solutionFilePath);
// return solution;
// }
} }

View File

@@ -0,0 +1,21 @@
using BenchmarkDotNet.Attributes;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
namespace Roslyn.Benchmarks;
public class ParseSolutionBenchmarks
{
private const string _solutionFilePath = "C:/Users/Matthew/Documents/Git/StatusApp/StatusApp.sln";
//[IterationSetup]
[Benchmark]
public async Task<Solution> ParseSolutionFileFromPath()
{
var workspace = MSBuildWorkspace.Create();
var solution = await workspace.OpenSolutionAsync(_solutionFilePath);
return solution;
}
}

View File

@@ -1,4 +1,5 @@
using BenchmarkDotNet.Running; using BenchmarkDotNet.Running;
using Roslyn.Benchmarks; using Roslyn.Benchmarks;
BenchmarkRunner.Run<MSBuildWorkspaceBenchmarks>(); //BenchmarkRunner.Run<CreateWorkspaceBenchmarks>();
BenchmarkRunner.Run<ParseSolutionBenchmarks>();